-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
31 lines (25 loc) · 914 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
URL_BEST = f"https://service-api.tver.jp/api/v1/callEpisodeRankingDetail/variety"
URL_VIDEO_WEBSITE = 'https://tver.jp/{}s/{}'
def extract_info(url):
from lib.yt_dlp import YoutubeDL
from lib.yt_dlp.extractor.tver import TVerIE
ydl_opts = {
'format': 'bestvideo*+bestaudio/best'
}
ydl = YoutubeDL(ydl_opts)
ydl.add_info_extractor(TVerIE())
info = ydl.extract_info(url, download=False)
return info
def get_valid_episode():
resp = requests.get(URL_BEST, headers={'x-tver-platform-type': 'web'}, timeout=10)
data = resp.json()
for episode in data['result']['contents']['contents']:
if episode['type'] == 'episode':
return URL_VIDEO_WEBSITE.format('episode', episode['content']['id'])
def test_tver():
url = get_valid_episode()
print(url)
assert url
info = extract_info(url)
assert info['manifest_url']