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