video['filename'] = video['title']+'.ts'
if 'statistics' in flashvars:
video['category'] = flashvars['statistics']['category']
- download_from_playlist(video)
+ if not download_from_playlist(video):
+ return False
if not 'url' in video:
print("Could not find any streams")
return False
segment=0
size = 0
for url in segments:
- ufile = requests.get(url, stream=True).raw
+ try:
+ ufile = requests.get(url, stream=True).raw
+ except:
+ print("Error reading, skipping file") #FIXME mark file as failed
+ print(sys.exc_info()[1])
+ return False
print("\r{0:.2f} MB".format(size/1024/1024),end="")
sys.stdout.flush()
if decrypt:
while(True):
try:
buf = ufile.read(4096)
- except (socket.error, TypeError) as e:
- print("Error reading, skipping file")
- print(e)
- return
+ except:
+ print("Error reading, skipping file") #FIXME mark file as failed
+ print(sys.exc_info()[1])
+ return False
if not buf:
break
if decrypt:
if 'thumb-url' in video:
video['thumb'] = requests.get(video['thumb-url'],stream=True).raw
+ return True
def parse_playlist(playlist):
if not playlist.startswith("#EXTM3U"):
os.utime(video['path'], times=(video['timestamp'].timestamp(),video['timestamp'].timestamp()))
except FileNotFoundError as e:
print(e)
-
+
def mkv_metadata(video):
root = BeautifulSoup(features='xml')
if args.no_act:
continue
open(os.path.join('.seen',video['title']),'w').close() #touch
- video = scrape_player_page(video)
+ ret = scrape_player_page(video)
+ if not ret:
+ if not os.path.exists('.failed'):
+ os.mkdir('.failed')
+ open(os.path.join('.failed',video['title']),'w').close() #touch
+ continue
+ video = ret
if args.no_remux:
continue
xml = mkv_metadata(video)