summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7370a42)
Fix setup.py dependencies.
author_email = "mikael@frykholm.com",
url = "https://github.com/mikaelfrykholm/svtplaydump",
keywords = ["svtplay"],
author_email = "mikael@frykholm.com",
url = "https://github.com/mikaelfrykholm/svtplaydump",
keywords = ["svtplay"],
- install_requires=['beautifulsoup4', 'feedparser', 'requests'],
+ install_requires=['beautifulsoup4', 'feedparser', 'requests>=1.2.1', 'pycrypto>=2.6.1','html5lib'],
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
print(Popen(["mplayer","-dumpstream","-dumpfile",filename, rtmp], stdout=PIPE).communicate()[0])
if 'video' in flashvars:
for reference in flashvars['video']['videoReferences']:
print(Popen(["mplayer","-dumpstream","-dumpfile",filename, rtmp], stdout=PIPE).communicate()[0])
if 'video' in flashvars:
for reference in flashvars['video']['videoReferences']:
- if reference['url'].endswith("m3u8"):
+ if 'm3u8' in reference['url']:
video['url']=reference['url']
video['filename'] = video['title']+'.ts'
if 'statistics' in flashvars:
video['category'] = flashvars['statistics']['category']
download_from_playlist(video)
video['url']=reference['url']
video['filename'] = video['title']+'.ts'
if 'statistics' in flashvars:
video['category'] = flashvars['statistics']['category']
download_from_playlist(video)
print("Could not find any streams")
print("Could not find any streams")
return video
def download_from_playlist(video):
return video
def download_from_playlist(video):
if not playlist:
return
videourl = sorted(playlist, key=lambda k: int(k['BANDWIDTH']))[-1]['url']
if not playlist:
return
videourl = sorted(playlist, key=lambda k: int(k['BANDWIDTH']))[-1]['url']
- segments, metadata = parse_segment_playlist(requests.get(videourl).text)
+ if not videourl.startswith('http'): #if relative path
+ videourl = "{}/{}".format(os.path.dirname(video['url']), videourl)
+ segments, metadata = parse_segment_playlist(videourl)
if "EXT-X-KEY" in metadata:
key = requests.get(metadata["EXT-X-KEY"]['URI'].strip('"')).text
decrypt=True
if "EXT-X-KEY" in metadata:
key = requests.get(metadata["EXT-X-KEY"]['URI'].strip('"')).text
decrypt=True
if not playlist.startswith("#EXTM3U"):
print(playlist)
return False
if not playlist.startswith("#EXTM3U"):
print(playlist)
return False
- playlist = playlist.splitlines()[1:]
+ playlist = playlist.splitlines()
+ while not 'EXT-X-STREAM-INF' in playlist[0]:
+ playlist = playlist[1:]
items=[]
for (metadata_string,url) in zip(playlist[0::2], playlist[1::2]):
md = dict()
items=[]
for (metadata_string,url) in zip(playlist[0::2], playlist[1::2]):
md = dict()
- assert 'EXT-X-STREAM-INF' in metadata_string.split(':')[0]
+ if not 'EXT-X-STREAM-INF' in metadata_string.split(':')[0]:
+ continue
for item in metadata_string.split(':')[1].split(','):
if '=' in item:
md.update([item.split('='),])
for item in metadata_string.split(':')[1].split(','):
if '=' in item:
md.update([item.split('='),])
items.append(md)
return items
items.append(md)
return items
-def parse_segment_playlist(playlist):
+def parse_segment_playlist(playlisturl):
+ playlist = requests.get(playlisturl).text
assert playlist.startswith("#EXTM3U")
PATTERN = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')
segments = []
assert playlist.startswith("#EXTM3U")
PATTERN = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')
segments = []
metadata = {}
for row in playlist.splitlines():
if next_is_url:
metadata = {}
for row in playlist.splitlines():
if next_is_url:
+ if not row.startswith('http'): #if relative path
+ row = "{}/{}".format(os.path.dirname(playlisturl), row)
segments.append(row)
next_is_url=False
continue
segments.append(row)
next_is_url=False
continue
yield video
page_num += 1
yield video
page_num += 1
+def remux(video):
+ basename = video['filename'].split('.ts')[0]
+ print(Popen(["avconv","-i",video['filename'],"-vcodec","copy","-acodec","copy", basename+'.mkv'], stdout=PIPE).communicate()[0])
+ try:
+ os.unlink(video['filename'])
+ except:
+ pass
if __name__ == "__main__":
parser = argparse.ArgumentParser()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
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")
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")
+ parser.add_argument("--no_remux", help="Don't remux into mkv", action="store_true")
+
args = parser.parse_args()
if args.rss:
import feedparser
args = parser.parse_args()
if args.rss:
import feedparser
if args.no_act:
continue
filename = scrape_player_page(e.link, 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])
+ if args.no_remux:
+ continue
+ self.remux({'title':e.title})
#print(e.description)
if args.mirror:
for video in parse_videolist():
#print(e.description)
if args.mirror:
for video in parse_videolist():
print("Downloading...")
if args.no_act:
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()
+ video = scrape_player_page(video['url'], video['title'])
+ if args.no_remux:
+ continue
+ remux(video)
else:
if not args.no_act:
video = scrape_player_page(args.url, None)
else:
if not args.no_act:
video = scrape_player_page(args.url, None)
+ if not args.no_remux:
+ remux({'title':e.title})
print(("Downloaded {}".format(args.url)))
print(("Downloaded {}".format(args.url)))