]>
git.frykholm.com Git - svtplaydump.git/blob - mirror-svtplay.py
94cb95670ff8014076e7f7297c6f5b1214c72a3b
2 from pathlib
import Path
8 totpages
= requests
.get("https://www.svtplay.se/api/latest").json()['totalPages']
9 for page
in range(1,totpages
):
10 resp
= requests
.get(f
"https://www.svtplay.se/api/latest?page={page}").json()
11 for video
in resp
['data']:
14 def find_genre(video
):
15 for cluster
in video
['clusters']:
16 if cluster
['clusterType'] == 'main':
17 return cluster
['name']
24 genre
= find_genre(video
)
28 if not video
['movie']: #We have a Series, make a folder
29 path
= Path(genre
) / Path(video
['programTitle'].replace('/','_'))
33 postprocessors
.append( { 'key': 'EmbedThumbnail', })
34 postprocessors
.append( { 'key': 'FFmpegMetadata', })
35 ydl_opts
= { 'download_archive': 'svtplay.archive',
36 'writesubtitles': True,
38 'writethumbnail': True,
39 'outtmpl' : f
'{path}/%(title)s-%(id)s.%(ext)s',
40 'postprocessors': postprocessors
, }
41 extra_info
= { 'id': video
['id'],
42 'title': video
['programTitle'] + ' - ' + video
['title'],
43 'description': video
.get('description',''),
44 'thumbnail':video
.get('thumbnail','').replace('{format}','large')}
46 with youtube_dl
.YoutubeDL(ydl_opts
) as ydl
:
47 ydl
.extract_info("http://svtplay.se/"+video
['contentUrl'], extra_info
=extra_info
)
49 if __name__
== "__main__":
50 for video
in videos():
51 print(video
['programTitle'])