mnamer 2.7.3.dev13__tar.gz → 2.7.3.dev15__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/AGENTS.md +6 -6
  2. {mnamer-2.7.3.dev13/mnamer.egg-info → mnamer-2.7.3.dev15}/PKG-INFO +7 -5
  3. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/README.md +6 -4
  4. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/__version__.py +1 -1
  5. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/argument.py +9 -0
  6. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/endpoints.py +10 -256
  7. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/language.py +0 -30
  8. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/metadata.py +0 -1
  9. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/providers.py +18 -206
  10. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/setting_spec.py +2 -1
  11. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/setting_store.py +36 -14
  12. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/target.py +1 -1
  13. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/types.py +0 -1
  14. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15/mnamer.egg-info}/PKG-INFO +7 -5
  15. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer.egg-info/SOURCES.txt +0 -2
  16. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer.egg-info/scm_file_list.json +46 -48
  17. mnamer-2.7.3.dev15/mnamer.egg-info/scm_version.json +8 -0
  18. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/pytest.ini +0 -1
  19. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/__init__.py +3 -55
  20. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/e2e/conftest.py +0 -77
  21. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/e2e/test_directives.py +38 -5
  22. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/e2e/test_moving.py +4 -19
  23. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_providers.py +5 -127
  24. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/test_endpoints__tvmaze.py +0 -19
  25. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/test_providers__tvmaze.py +0 -29
  26. mnamer-2.7.3.dev13/mnamer.egg-info/scm_version.json +0 -8
  27. mnamer-2.7.3.dev13/tests/network/test_endpoints__tvdb.py +0 -386
  28. mnamer-2.7.3.dev13/tests/network/test_providers__tvdb.py +0 -110
  29. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.dockerignore +0 -0
  30. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/actions/init/action.yml +0 -0
  31. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/actions/lint/action.yml +0 -0
  32. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/actions/test/action.yml +0 -0
  33. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/dependabot.yml +0 -0
  34. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/workflows/publish-docker.yml +0 -0
  35. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/workflows/publish.yml +0 -0
  36. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/workflows/pull_request.yml +0 -0
  37. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.github/workflows/push.yml +0 -0
  38. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.gitignore +0 -0
  39. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.python-version +0 -0
  40. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/.vscode/settings.json +0 -0
  41. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/CLAUDE.md +0 -0
  42. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/Dockerfile +0 -0
  43. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/LICENSE.txt +0 -0
  44. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/MANIFEST.in +0 -0
  45. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/design.eps +0 -0
  46. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/logo-2.png +0 -0
  47. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/logo-3.png +0 -0
  48. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/logo.png +0 -0
  49. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/recording.mov +0 -0
  50. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/screenshot.eps +0 -0
  51. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/assets/screenshot.png +0 -0
  52. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/makefile +0 -0
  53. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/__init__.py +0 -0
  54. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/__main__.py +0 -0
  55. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/const.py +0 -0
  56. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/exceptions.py +0 -0
  57. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/frontends.py +0 -0
  58. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/py.typed +0 -0
  59. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/tty.py +0 -0
  60. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer/utils.py +0 -0
  61. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer.egg-info/dependency_links.txt +0 -0
  62. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer.egg-info/entry_points.txt +0 -0
  63. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer.egg-info/requires.txt +0 -0
  64. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/mnamer.egg-info/top_level.txt +0 -0
  65. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/pyproject.toml +0 -0
  66. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/setup.cfg +0 -0
  67. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/conftest.py +0 -0
  68. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/e2e/__init__.py +0 -0
  69. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/e2e/test_errors.py +0 -0
  70. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/__init__.py +0 -0
  71. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_argument.py +0 -0
  72. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_language.py +0 -0
  73. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_metadata.py +0 -0
  74. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_setting_spec.py +0 -0
  75. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_setting_store.py +0 -0
  76. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_target.py +0 -0
  77. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_tty.py +0 -0
  78. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/local/test_utils.py +0 -0
  79. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/__init__.py +0 -0
  80. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/test_endpoints__omdb.py +0 -0
  81. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/test_endpoints__tmdb.py +0 -0
  82. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/test_providers__omdb.py +0 -0
  83. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/tests/network/test_providers__tmdb.py +0 -0
  84. {mnamer-2.7.3.dev13 → mnamer-2.7.3.dev15}/uv.lock +0 -0
@@ -4,7 +4,7 @@ This file provides guidance to LLMs when working with code in this repository.
4
4
 
5
5
  ## Project Overview
6
6
 
7
- mnamer (media renamer) is a command-line utility for organizing media files. It parses filenames for metadata using guessit, queries metadata providers (TMDb, OMDb, TVDb, TvMaze), and intelligently renames/moves files based on configurable templates.
7
+ mnamer (media renamer) is a command-line utility for organizing media files. It parses filenames for metadata using guessit, queries metadata providers (TMDb, OMDb, TvMaze), and intelligently renames/moves files based on configurable templates.
8
8
 
9
9
  ## Development Setup
10
10
 
@@ -47,7 +47,7 @@ uv run pytest tests/local/test_metadata.py::test_function_name
47
47
  ```
48
48
 
49
49
  Registered markers are declared in `pytest.ini`: `local`, `network`, `e2e`,
50
- plus provider markers `omdb`, `tmdb`, `tvdb`, and `tvmaze`.
50
+ plus provider markers `omdb`, `tmdb`, and `tvmaze`.
51
51
 
52
52
  ### Linting and Formatting
53
53
 
@@ -71,10 +71,10 @@ uv run mypy mnamer tests
71
71
  3. **Target** (`target.py:Target`): Represents a media file, manages its metadata and relocation
72
72
  4. **Metadata** (`metadata.py`): Dataclasses for storing parsed and enriched metadata
73
73
  - `MetadataMovie`: Movie-specific fields (name, year, id_imdb, id_tmdb)
74
- - `MetadataEpisode`: TV episode fields (series, season, episode, id_tvdb, id_tvmaze)
74
+ - `MetadataEpisode`: TV episode fields (series, season, episode, id_tvmaze)
75
75
  5. **Providers** (`providers.py`): High-level interface for querying metadata APIs
76
76
  - `Tmdb`, `Omdb`: Movie providers
77
- - `Tvdb`, `Tvmaze`: TV episode providers
77
+ - `TvMaze`: TV episode provider
78
78
  6. **Endpoints** (`endpoints.py`): Low-level API request functions and response TypedDicts
79
79
 
80
80
  ### Key Architectural Patterns
@@ -111,13 +111,13 @@ uv run mypy mnamer tests
111
111
  - **Config File**: `.mnamer-v2.json` in the current or parent directories, or the explicit path from `--config-path`
112
112
  - **Settings Precedence**: CLI arguments > config file > defaults
113
113
  - **Directives vs Parameters**: Directives (like `--test`, `--id-tmdb`) are one-time overrides not stored in config files
114
- - **Config-only Fields**: `api_key_omdb`, `api_key_tmdb`, `api_key_tvdb`, `api_key_tvmaze`, `replace_before`, and `replace_after` are only loaded from config/defaults, not CLI flags
114
+ - **Config-only Fields**: `api_key_omdb`, `api_key_tmdb`, `api_key_tvmaze`, `replace_before`, and `replace_after` are only loaded from config/defaults, not CLI flags
115
115
 
116
116
  ## API Keys
117
117
 
118
118
  Providers load API keys through `Provider.from_settings()` using config-only
119
119
  fields named `api_key_<provider>`. If unset, provider classes fall back to
120
- environment variables (`API_KEY_OMDB`, `API_KEY_TMDB`, `API_KEY_TVDB`,
120
+ environment variables (`API_KEY_OMDB`, `API_KEY_TMDB`,
121
121
  `API_KEY_TVMAZE`) and then bundled defaults where present.
122
122
 
123
123
  Check provider classes in `providers.py` for API key handling via `from_settings()` class method.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mnamer
3
- Version: 2.7.3.dev13
3
+ Version: 2.7.3.dev15
4
4
  Summary: A command-line utility for organizing media files.
5
5
  Author-email: Jessy Williams <jessy@jessywilliams.com>
6
6
  Maintainer-email: Jessy Williams <jessy@jessywilliams.com>
@@ -47,11 +47,14 @@ Dynamic: license-file
47
47
 
48
48
  <img src="https://github.com/jkwill87/mnamer/raw/main/assets/logo.png" width="450"/>
49
49
 
50
+ > [!NOTE]
51
+ > mnamer is currently under an early development rust rewrite, available under the [v3](https://github.com/jkwill87/mnamer/tree/v3) branch. While a WIP and extremely subject to change, it currently has feature parity with v2, as well as new features like file metadata introspection and hard linking. v2 will continue to be maintained for the forseeable fututure, but if you're feeling adventerous feel free to check it out and leave feedback under a discussion thread!
52
+
50
53
  # mnamer
51
54
 
52
55
  mnamer (**m**edia re**namer**) is an intelligent and highly configurable media organization utility. It parses media filenames for metadata, searches the web to fill in the blanks, and then renames and moves them.
53
56
 
54
- Currently it has integration support with [TVDb](https://thetvdb.com) and [TvMaze](https://www.tvmaze.com) for television episodes and [TMDb](https://www.themoviedb.org/) and [OMDb](https://www.omdbapi.com) for movies.
57
+ Currently it has integration support with [TvMaze](https://www.tvmaze.com) for television episodes and [TMDb](https://www.themoviedb.org/) and [OMDb](https://www.omdbapi.com) for movies.
55
58
 
56
59
  <img src="https://github.com/jkwill87/mnamer/raw/main/assets/screenshot.png" width="750"/>
57
60
 
@@ -73,7 +76,7 @@ Using the **episode-directory**, **episode-format**, **movie-directory**, or **m
73
76
 
74
77
  🌐 [**Internationalization**](https://github.com/jkwill87/mnamer/wiki/Internationalization)
75
78
 
76
- Language is supported by the default TMDb and TVDb providers. You can use the `--language` setting to set the language used for templating.
79
+ Language is supported by the default TMDb provider. You can use the `--language` setting to set the language used for templating.
77
80
 
78
81
  mnamer also supports subtitle files (.srt, .idx, .sub). It will use the format pattern used for movie or episode media files with its extension prefixed by its 2-letter language code.
79
82
 
@@ -105,7 +108,7 @@ PARAMETERS:
105
108
  --movie-api={*tmdb,omdb}: set movie api provider
106
109
  --movie-directory: set movie relocation directory
107
110
  --movie-format: set movie renaming format specification
108
- --episode-api={tvdb,*tvmaze}: set episode api provider
111
+ --episode-api={tvmaze}: set episode api provider
109
112
  --episode-directory: set episode relocation directory
110
113
  --episode-format: set episode renaming format specification
111
114
 
@@ -120,7 +123,6 @@ DIRECTIVES:
120
123
  --config-path=<PATH>: specifies configuration path to load
121
124
  --id-imdb=<ID>: specify an IMDb movie id override
122
125
  --id-tmdb=<ID>: specify a TMDb movie id override
123
- --id-tvdb=<ID>: specify a TVDb series id override
124
126
  --id-tvmaze=<ID>: specify a TvMaze series id override
125
127
  --no-cache: disable request cache
126
128
  --media={movie,episode}: override media detection
@@ -6,11 +6,14 @@
6
6
 
7
7
  <img src="https://github.com/jkwill87/mnamer/raw/main/assets/logo.png" width="450"/>
8
8
 
9
+ > [!NOTE]
10
+ > mnamer is currently under an early development rust rewrite, available under the [v3](https://github.com/jkwill87/mnamer/tree/v3) branch. While a WIP and extremely subject to change, it currently has feature parity with v2, as well as new features like file metadata introspection and hard linking. v2 will continue to be maintained for the forseeable fututure, but if you're feeling adventerous feel free to check it out and leave feedback under a discussion thread!
11
+
9
12
  # mnamer
10
13
 
11
14
  mnamer (**m**edia re**namer**) is an intelligent and highly configurable media organization utility. It parses media filenames for metadata, searches the web to fill in the blanks, and then renames and moves them.
12
15
 
13
- Currently it has integration support with [TVDb](https://thetvdb.com) and [TvMaze](https://www.tvmaze.com) for television episodes and [TMDb](https://www.themoviedb.org/) and [OMDb](https://www.omdbapi.com) for movies.
16
+ Currently it has integration support with [TvMaze](https://www.tvmaze.com) for television episodes and [TMDb](https://www.themoviedb.org/) and [OMDb](https://www.omdbapi.com) for movies.
14
17
 
15
18
  <img src="https://github.com/jkwill87/mnamer/raw/main/assets/screenshot.png" width="750"/>
16
19
 
@@ -32,7 +35,7 @@ Using the **episode-directory**, **episode-format**, **movie-directory**, or **m
32
35
 
33
36
  🌐 [**Internationalization**](https://github.com/jkwill87/mnamer/wiki/Internationalization)
34
37
 
35
- Language is supported by the default TMDb and TVDb providers. You can use the `--language` setting to set the language used for templating.
38
+ Language is supported by the default TMDb provider. You can use the `--language` setting to set the language used for templating.
36
39
 
37
40
  mnamer also supports subtitle files (.srt, .idx, .sub). It will use the format pattern used for movie or episode media files with its extension prefixed by its 2-letter language code.
38
41
 
@@ -64,7 +67,7 @@ PARAMETERS:
64
67
  --movie-api={*tmdb,omdb}: set movie api provider
65
68
  --movie-directory: set movie relocation directory
66
69
  --movie-format: set movie renaming format specification
67
- --episode-api={tvdb,*tvmaze}: set episode api provider
70
+ --episode-api={tvmaze}: set episode api provider
68
71
  --episode-directory: set episode relocation directory
69
72
  --episode-format: set episode renaming format specification
70
73
 
@@ -79,7 +82,6 @@ DIRECTIVES:
79
82
  --config-path=<PATH>: specifies configuration path to load
80
83
  --id-imdb=<ID>: specify an IMDb movie id override
81
84
  --id-tmdb=<ID>: specify a TMDb movie id override
82
- --id-tvdb=<ID>: specify a TVDb series id override
83
85
  --id-tvmaze=<ID>: specify a TvMaze series id override
84
86
  --no-cache: disable request cache
85
87
  --media={movie,episode}: override media detection
@@ -1,4 +1,4 @@
1
1
  # file generated by setuptools_scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __version__ = "2.7.3.dev13"
4
+ __version__ = "2.7.3.dev15"
@@ -2,6 +2,7 @@ import argparse
2
2
  from typing import Any, final, override
3
3
 
4
4
  from mnamer.const import USAGE
5
+ from mnamer.exceptions import MnamerException
5
6
  from mnamer.setting_spec import SettingSpec
6
7
  from mnamer.types import SettingType
7
8
 
@@ -72,6 +73,14 @@ class ArgLoader(argparse.ArgumentParser):
72
73
 
73
74
  def load(self) -> dict[str, Any]:
74
75
  load_arguments, unknowns = self.parse_known_args()
76
+ if any(
77
+ arg.partition("=")[0] in {"--id-tvdb", "--id_tvdb", "--idtvdb"}
78
+ for arg in unknowns
79
+ ):
80
+ raise MnamerException(
81
+ "TVDb IDs are no longer supported. "
82
+ "Use --id-tvmaze with a TVmaze series ID."
83
+ )
75
84
  if unknowns:
76
85
  raise RuntimeError(f"invalid arguments: {','.join(unknowns)}")
77
86
  return vars(load_arguments)
@@ -69,46 +69,7 @@ class TmdbSearchResponse(TypedDict):
69
69
  total_results: int
70
70
 
71
71
 
72
- class TvdbLinks(TypedDict):
73
- last: int
74
- next: int | None
75
- prev: int | None
76
-
77
-
78
- class TvdbSeriesData(TypedDict):
79
- id: int
80
- series_name: str
81
-
82
-
83
- class TvdbSeriesResponse(TypedDict):
84
- data: TvdbSeriesData
85
-
86
-
87
- class TvdbEpisodeEntry(TypedDict):
88
- id: int
89
- first_aired: str
90
- aired_episode_number: int
91
- aired_season: int
92
- overview: str | None
93
- episode_name: str
94
-
95
-
96
- class TvdbEpisodesResponse(TypedDict):
97
- data: list[TvdbEpisodeEntry]
98
- links: TvdbLinks
99
-
100
-
101
- class TvdbSearchEntry(TypedDict):
102
- id: int
103
- series_name: str
104
-
105
-
106
- class TvdbSearchResponse(TypedDict):
107
- data: list[TvdbSearchEntry]
108
-
109
-
110
72
  class TvMazeExternals(TypedDict):
111
- thetvdb: int | str | None
112
73
  imdb: NotRequired[str | None]
113
74
 
114
75
 
@@ -226,7 +187,11 @@ def tmdb_find(
226
187
 
227
188
  Online docs: developers.themoviedb.org/3/find.
228
189
  """
229
- sources = ["imdb_id", "freebase_mid", "freebase_id", "tvdb_id", "tvrage_id"]
190
+ if external_source == "tvdb_id":
191
+ raise MnamerException(
192
+ "TVDb IDs are no longer supported. Use imdb_id with an IMDb ID."
193
+ )
194
+ sources = ["imdb_id", "freebase_mid", "freebase_id", "tvrage_id"]
230
195
  if external_source not in sources:
231
196
  raise MnamerException(f"external_source must be in {sources}")
232
197
  if external_source == "imdb_id" and not match(r"tt\d+", external_id):
@@ -315,216 +280,6 @@ def tmdb_search_movies(
315
280
  return cast(TmdbSearchResponse, content)
316
281
 
317
282
 
318
- def tvdb_login(api_key: str) -> str:
319
- """
320
- Logs into TVDb using the provided api key.
321
-
322
- Note: You can register for a free TVDb key at thetvdb.com/?tab=apiregister
323
- Online docs: api.thetvdb.com/swagger#!/Authentication/post_login.
324
- """
325
- url = "https://api.thetvdb.com/login"
326
- body = {"apikey": api_key}
327
- status, content = request_json(url, body=body, cache=False)
328
- if status == 401:
329
- raise MnamerException("invalid api key")
330
- elif status != 200 or not content.get("token"): # pragma: no cover
331
- raise MnamerNetworkException("TVDb down or unavailable?")
332
- return content["token"]
333
-
334
-
335
- def tvdb_refresh_token(token: str) -> str:
336
- """
337
- Refreshes JWT token.
338
-
339
- Online docs: api.thetvdb.com/swagger#!/Authentication/get_refresh_token.
340
- """
341
- url = "https://api.thetvdb.com/refresh_token"
342
- headers = _tvdb_headers(token)
343
- status, content = request_json(url, headers=headers, cache=False)
344
- if status == 401:
345
- raise MnamerException("invalid token")
346
- elif status != 200 or not content.get("token"): # pragma: no cover
347
- raise MnamerNetworkException("TVDb down or unavailable?")
348
- return content["token"]
349
-
350
-
351
- def _tvdb_headers(token: str, language: Language | None = None) -> dict[str, str]:
352
- if token.count(".") != 2:
353
- raise MnamerException("invalid token")
354
- headers = {"Authorization": f"Bearer {token}"}
355
- if language:
356
- headers["Accept-Language"] = language.a2
357
- return headers
358
-
359
-
360
- def tvdb_episodes_id(
361
- token: str,
362
- id_tvdb: str,
363
- language: Language | None = None,
364
- cache: bool = True,
365
- ) -> dict[str, Any]:
366
- """
367
- Returns the full information for a given episode id.
368
-
369
- Online docs: https://api.thetvdb.com/swagger#!/Episodes.
370
- """
371
- Language.ensure_valid_for_tvdb(language)
372
- url = f"https://api.thetvdb.com/episodes/{id_tvdb}"
373
- headers = _tvdb_headers(token, language)
374
- status, content = request_json(
375
- url, headers=headers, cache=cache is True and language is None
376
- )
377
- content = normalize_keys(content)
378
- if status == 401:
379
- raise MnamerException("invalid token")
380
- elif status == 404 or not content.get("data"):
381
- raise MnamerNotFoundException
382
- elif status != 200: # pragma: no cover
383
- raise MnamerNetworkException("TVDb down or unavailable?")
384
- elif content["data"]["id"] == 0:
385
- raise MnamerNotFoundException
386
- return content
387
-
388
-
389
- def tvdb_series_id(
390
- token: str,
391
- id_tvdb: str,
392
- language: Language | None = None,
393
- cache: bool = True,
394
- ) -> TvdbSeriesResponse:
395
- """
396
- Returns a series records that contains all information known about a
397
- particular series id.
398
-
399
- Online docs: api.thetvdb.com/swagger#!/Series/get_series_id.
400
- """
401
- Language.ensure_valid_for_tvdb(language)
402
- url = f"https://api.thetvdb.com/series/{id_tvdb}"
403
- headers = _tvdb_headers(token, language)
404
- status, content = request_json(
405
- url, headers=headers, cache=cache is True and language is None
406
- )
407
- content = normalize_keys(content)
408
- if status == 401:
409
- raise MnamerException("invalid token")
410
- elif status == 404 or not content.get("data"):
411
- raise MnamerNotFoundException
412
- elif status != 200: # pragma: no cover
413
- raise MnamerNetworkException("TVDb down or unavailable?")
414
- elif content["data"]["id"] == 0:
415
- raise MnamerNotFoundException
416
- return cast(TvdbSeriesResponse, content)
417
-
418
-
419
- def tvdb_series_id_episodes(
420
- token: str,
421
- id_tvdb: str,
422
- page: int = 1,
423
- language: Language | None = None,
424
- cache: bool = True,
425
- ) -> TvdbEpisodesResponse:
426
- """
427
- All episodes for a given series.
428
-
429
- Note: Paginated with 100 results per page.
430
- Online docs: api.thetvdb.com/swagger#!/Series/get_series_id_episodes.
431
- """
432
- Language.ensure_valid_for_tvdb(language)
433
- url = f"https://api.thetvdb.com/series/{id_tvdb}/episodes"
434
- headers = _tvdb_headers(token, language)
435
- parameters: dict[str, Any] = {"page": page}
436
- status, content = request_json(
437
- url, parameters, headers=headers, cache=cache is True and language is None
438
- )
439
- content = normalize_keys(content)
440
- if status == 401:
441
- raise MnamerException("invalid token")
442
- elif status == 404 or not content.get("data"):
443
- raise MnamerNotFoundException
444
- elif status != 200: # pragma: no cover
445
- raise MnamerNetworkException("TVDb down or unavailable?")
446
- return cast(TvdbEpisodesResponse, content)
447
-
448
-
449
- def tvdb_series_id_episodes_query(
450
- token: str,
451
- id_tvdb: str,
452
- episode: int | None = None,
453
- season: int | None = None,
454
- page: int = 1,
455
- language: Language | None = None,
456
- cache: bool = True,
457
- ) -> TvdbEpisodesResponse:
458
- """
459
- Allows the user to query against episodes for the given series.
460
-
461
- Note: Paginated with 100 results per page; omitted imdbId-- when would you
462
- ever need to query against both tvdb and imdb series ids?
463
- Online docs: api.thetvdb.com/swagger#!/Series/get_series_id_episodes_query.
464
- """
465
- Language.ensure_valid_for_tvdb(language)
466
- url = f"https://api.thetvdb.com/series/{id_tvdb}/episodes/query"
467
- headers = _tvdb_headers(token, language)
468
- parameters: dict[str, Any] = {
469
- "airedSeason": season,
470
- "airedEpisode": episode,
471
- "page": page,
472
- }
473
- status, content = request_json(
474
- url,
475
- parameters,
476
- headers=headers,
477
- cache=cache is True and language is None,
478
- )
479
- content = normalize_keys(content)
480
- if status == 401:
481
- raise MnamerException("invalid token")
482
- elif status == 404 or not content.get("data"):
483
- raise MnamerNotFoundException
484
- elif status != 200: # pragma: no cover
485
- raise MnamerNetworkException("TVDb down or unavailable?")
486
- return cast(TvdbEpisodesResponse, content)
487
-
488
-
489
- def tvdb_search_series(
490
- token: str,
491
- series: str | None = None,
492
- id_imdb: str | None = None,
493
- id_zap2it: str | None = None,
494
- language: Language | None = None,
495
- cache: bool = True,
496
- ) -> TvdbSearchResponse:
497
- """
498
- Allows the user to search for a series based on the following parameters.
499
-
500
- Online docs: https://api.thetvdb.com/swagger#!/Search/get_search_series
501
- Note: results a maximum of 100 entries per page, no option for pagination.
502
- """
503
- Language.ensure_valid_for_tvdb(language)
504
- url = "https://api.thetvdb.com/search/series"
505
- parameters: dict[str, Any] = {
506
- "name": series,
507
- "imdbId": id_imdb,
508
- "zap2itId": id_zap2it,
509
- }
510
- headers = _tvdb_headers(token, language)
511
- status, content = request_json(
512
- url, parameters, headers=headers, cache=cache is True and language is None
513
- )
514
- content = normalize_keys(content)
515
- if status == 401:
516
- raise MnamerException("invalid token")
517
- elif status == 405:
518
- raise MnamerException(
519
- "series, id_imdb, id_zap2it parameters are mutually exclusive"
520
- )
521
- elif status == 404 or not content.get("data"):
522
- raise MnamerNotFoundException
523
- elif status != 200: # pragma: no cover
524
- raise MnamerNetworkException("TVDb down or unavailable?")
525
- return cast(TvdbSearchResponse, content)
526
-
527
-
528
283
  def tvmaze_show(
529
284
  id_tvmaze: str,
530
285
  embed_episodes: bool = False,
@@ -601,24 +356,23 @@ def tvmaze_show_single_search(
601
356
 
602
357
  def tvmaze_show_lookup(
603
358
  id_imdb: str | None = None,
604
- id_tvdb: str | None = None,
605
359
  cache: bool = True,
606
360
  attempt: int = 1,
607
361
  ) -> TvMazeShow:
608
362
  """
609
- If you already know a show's tvrage, thetvdb or IMDB ID, you can use this
363
+ If you already know a show's IMDb ID, you can use this
610
364
  endpoint to find this exact show on TVmaze.
611
365
 
612
366
  Online docs: https://www.tvmaze.com/api#show-lookup
613
367
  """
614
- if not [id_imdb, id_tvdb].count(None) == 1:
615
- raise MnamerException("id_imdb and id_tvdb are mutually exclusive")
368
+ if id_imdb is None:
369
+ raise MnamerException("id_imdb is required")
616
370
  url = "http://api.tvmaze.com/lookup/shows"
617
- parameters: dict[str, Any] = {"imdb": id_imdb, "thetvdb": id_tvdb}
371
+ parameters: dict[str, Any] = {"imdb": id_imdb}
618
372
  status, content = request_json(url, parameters, cache=cache)
619
373
  if status == 443 and attempt <= MAX_RETRIES: # pragma: no cover
620
374
  sleep(attempt * 2)
621
- return tvmaze_show_lookup(id_imdb, id_tvdb, cache, attempt + 1)
375
+ return tvmaze_show_lookup(id_imdb, cache, attempt + 1)
622
376
  elif status == 404:
623
377
  raise MnamerNotFoundException
624
378
  elif status != 200 or not content: # pragma: no cover
@@ -71,33 +71,3 @@ class Language:
71
71
  @override
72
72
  def __str__(self) -> str:
73
73
  return self.a2
74
-
75
- @staticmethod
76
- def ensure_valid_for_tvdb(language: Language | None):
77
- valid = {
78
- "cs",
79
- "da",
80
- "de",
81
- "el",
82
- "en",
83
- "es",
84
- "fi",
85
- "fr",
86
- "he",
87
- "hr",
88
- "hu",
89
- "it",
90
- "ja",
91
- "ko",
92
- "nl",
93
- "no",
94
- "pl",
95
- "pt",
96
- "ru",
97
- "sl",
98
- "sv",
99
- "tr",
100
- "zh",
101
- }
102
- if language is not None and language.a2 not in valid:
103
- raise MnamerException(f"'lang' must be one of {','.join(valid)}")
@@ -153,7 +153,6 @@ class MetadataEpisode(Metadata):
153
153
  episode: int | None = None
154
154
  date: dt.date | None = None
155
155
  title: str | None = None
156
- id_tvdb: str | None = None
157
156
  id_tvmaze: str | None = None
158
157
 
159
158
  def __post_init__(self):