+ parser = argparse.ArgumentParser()
+ group = parser.add_mutually_exclusive_group(required=True)
+ group.add_argument("-r", "--rss", help="Download all files in rss")
+ group.add_argument("-u", "--url", help="Download video in url")
+ group.add_argument("-m", "--mirror", help="Mirror all files", action="store_true")
+ parser.add_argument("-n", "--no_act", help="Just print what would be done, don't do any downloading.", action="store_true")
+ args = parser.parse_args()
+ if args.rss:
+ d = feedparser.parse(args.rss)
+ for e in d.entries:
+ print("Downloading: %s"%e.title)
+ if args.no_act:
+ continue
+ filename = scrape_player_page(e.link, e.title)
+ print Popen(["avconv","-i",filename,"-vcodec","copy","-acodec","copy", filename+'.mkv'], stdout=PIPE).communicate()[0]
+ #print(e.description)
+ if args.mirror:
+ for video in parse_videolist():
+ video['title'] = video['title'].replace('/','_')
+ print video['title']+'.mkv',
+ print u"{} of {}".format(video['num'], video['total'])
+ if os.path.exists(video['title']+'.mkv'):
+ print "Skipping"
+ continue
+ print("Downloading...")
+ if args.no_act:
+ continue
+ ret = scrape_player_page(video['url'], video['title'])
+ print ret
+ print Popen(["avconv","-i",video['title']+'.ts',"-vcodec","copy","-acodec","copy", video['title']+'.mkv'], stdout=PIPE).communicate()[0]
+ try:
+ os.unlink(video['title']+'.ts')
+ except:
+ import pdb;pdb.set_trace()
+ else:
+ if not args.no_act:
+ video = scrape_player_page(args.url, None)
+ print(u"Downloaded {}".format(args.url))
\ No newline at end of file