From a285500fbcf69cbedf2df5cf028abeba1108ea50 Mon Sep 17 00:00:00 2001 From: garret Date: Tue, 2 Apr 2024 08:53:55 +0100 Subject: sort out package "building" and metadata --- .gitignore | 3 ++- pyproject.toml | 23 ++++++++++++++++++++--- setup.cfg | 6 ------ test_tokens.py | 26 -------------------------- tests/test_randominfo.py | 14 ++++++++++++++ tests/test_tokens.py | 26 ++++++++++++++++++++++++++ yt_dlp_plugins/extractor/radiko.py | 2 ++ 7 files changed, 64 insertions(+), 36 deletions(-) delete mode 100644 setup.cfg delete mode 100755 test_tokens.py create mode 100755 tests/test_randominfo.py create mode 100755 tests/test_tokens.py diff --git a/.gitignore b/.gitignore index 0ccbe0b..04a43b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ *.egg-info/ *.pyc -doc/ +wiki/ +dist/ diff --git a/pyproject.toml b/pyproject.toml index 97057d9..0b7ce66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,23 @@ +[project] +name = "yt-dlp-rajiko" +version = "1.0" +description = "improved radiko.jp extractor for yt-dlp" +authors = [ + { name="garret1317" }, +] +requires-python = ">=3.8" +dependencies = ["yt-dlp>=2023.06.22"] +classifiers = [ + "License :: OSI Approved :: Zero-Clause BSD (0BSD)", + "Environment :: Plugins", +] + +[project.urls] +Homepage = "https://427738.xyz/yt-dlp-rajiko/" + [build-system] -requires = ["setuptools"] +requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" -[tool.distutils.bdist_wheel] -universal = true +[tool.setuptools.packages.find] +include = ["yt_dlp_plugins"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5dce721..0000000 --- a/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[metadata] -name = yt-dlp-rajiko -version = 0.3.1 - -[options] -packages = find_namespace: diff --git a/test_tokens.py b/test_tokens.py deleted file mode 100755 index ba6475f..0000000 --- a/test_tokens.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -import unittest - -from yt_dlp_plugins.extractor import radiko -from yt_dlp import YoutubeDL - - -class test_tokens(unittest.TestCase): - - def setUp(self): - self.ie = radiko._RadikoBaseIE() - ydl = YoutubeDL(auto_init=False) - self.ie.set_downloader(ydl) - - def test_area(self): - # check areas etc work - for i in range(1, 48): - area = "JP" + str(i) - with self.subTest(f"Negotiating token for {area}", area=area): - token = self.ie._negotiate_token(area) - self.assertEqual(token.get("X-Radiko-AreaId"), area) - - -if __name__ == '__main__': - unittest.main() - # may wish to set failfast=True diff --git a/tests/test_randominfo.py b/tests/test_randominfo.py new file mode 100755 index 0000000..bd71fdc --- /dev/null +++ b/tests/test_randominfo.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +import unittest + +from yt_dlp_plugins.extractor import radiko +from yt_dlp import YoutubeDL + + +ie = radiko._RadikoBaseIE() +ydl = YoutubeDL(auto_init=False) +ie.set_downloader(ydl) + +info = ie._generate_random_info() +print("random device info") +print(info) diff --git a/tests/test_tokens.py b/tests/test_tokens.py new file mode 100755 index 0000000..ba6475f --- /dev/null +++ b/tests/test_tokens.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +import unittest + +from yt_dlp_plugins.extractor import radiko +from yt_dlp import YoutubeDL + + +class test_tokens(unittest.TestCase): + + def setUp(self): + self.ie = radiko._RadikoBaseIE() + ydl = YoutubeDL(auto_init=False) + self.ie.set_downloader(ydl) + + def test_area(self): + # check areas etc work + for i in range(1, 48): + area = "JP" + str(i) + with self.subTest(f"Negotiating token for {area}", area=area): + token = self.ie._negotiate_token(area) + self.assertEqual(token.get("X-Radiko-AreaId"), area) + + +if __name__ == '__main__': + unittest.main() + # may wish to set failfast=True diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index 4317ad0..15b49f3 100644 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -19,6 +19,8 @@ import yt_dlp_plugins.extractor.radiko_time as rtime class _RadikoBaseIE(InfoExtractor): + # TODO: replace with importlib.resources when yt-dlp minimum python version is new enough + # https://setuptools.pypa.io/en/latest/userguide/datafiles.html _FULL_KEY = base64.b64decode(""" fAu/s1ySbQBAyfugPCOniGTrMcOu5XqKcup3tmrZUAvx3MGtIIZl7wHokm07yxzL/oR9jdgWhi+e WYVoBIiAG4hDOP5H0Og3Qtd9KFnW8s0N4vNN2DzQ1Y4PqDq3HsQszf4ZaDTkyt4FFW9fPqKUtnVR -- cgit v1.2.3-70-g09d2