]>
git.frykholm.com Git - svtplaydump.git/blob - tv4playdump.py
3a33464981c95a39a14aa66f182d44acc83dcbca
1 #!/usr/bin/env python3.4
6 from pathlib
import Path
9 def get_hls_playlist(url
):
10 ret
= requests
.get(url
).json()
11 #import pdb;pdb.set_trace()
13 if isinstance(ret
['playback']['items']['item'], list):
14 videourl
= sorted(ret
['playback']['items']['item'], key
=lambda k
: int(k
['bitrate']))[-1]['url']
16 videourl
= ret
['playback']['items']['item']['url']
19 res
= requests
.get("http://webapi.tv4play.se/video/programs/search.json?categoryids=pokemon&start=0&rows=1000").json()
21 #import pdb;pdb.set_trace()
22 for vid
in res
['results']:
24 video
['title'] = vid
['name']
25 video
['description'] = vid
['lead']
26 video
['url'] = get_hls_playlist("http://premium.tv4play.se/api/web/asset/{}/play.json?protocol=hls&videoFormat=MP4+WVM+SMI".format(vid
['href']))
27 video
['filename'] = Path("{} {}.ts".format(vid
['ontime'],vid
['name']))
29 if video
['filename'].with_suffix('.mkv').exists():
30 print("Skipping {}".format(video
['filename'].with_suffix('.mkv')))
32 svtplaydump
.download_from_playlist(video
)
33 svtplaydump
.remux(video
)