import urllib import os import time server='' hash='' print 'Connected to server',server print 'Cam hash:',hash try: os.mkdir(hash) print 'Creating dir' except: print 'Dir already exsists' while 1: page = urllib.urlopen("http://%s/variant.m3u8?cid=%s&var=orig"%(server,hash)).read() for i in page.split('\n')[6::2]: print 'Dumping',i[-13:-3] f=open('./%s/%s.ts'%(hash,i[-13:-3]),'wb') page = urllib.urlopen("http://188.254.112.50"+i).read() f.write(page) f.close() time.sleep(60)