Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kuriho committed Jun 1, 2023
1 parent ac9a147 commit 5bbfcbf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.pyc
Empty file added lib/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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']

0 comments on commit 5bbfcbf

Please sign in to comment.