mnamer 2.7.3.dev13__py3-none-any.whl → 2.7.3.dev15__py3-none-any.whl

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.
mnamer/__version__.py CHANGED
@@ -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"
mnamer/argument.py CHANGED
@@ -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)
mnamer/endpoints.py CHANGED
@@ -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
mnamer/language.py CHANGED
@@ -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)}")
mnamer/metadata.py CHANGED
@@ -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):
mnamer/providers.py CHANGED
@@ -15,15 +15,10 @@ from mnamer.endpoints import (
15
15
  omdb_title,
16
16
  tmdb_movies,
17
17
  tmdb_search_movies,
18
- tvdb_login,
19
- tvdb_search_series,
20
- tvdb_series_id,
21
- tvdb_series_id_episodes_query,
22
18
  tvmaze_episode_by_number,
23
19
  tvmaze_episodes_by_date,
24
20
  tvmaze_show,
25
21
  tvmaze_show_episodes_list,
26
- tvmaze_show_lookup,
27
22
  tvmaze_show_search,
28
23
  )
29
24
  from mnamer.exceptions import MnamerNotFoundException
@@ -70,11 +65,6 @@ class Provider[M: Metadata](ABC):
70
65
  ) -> Tmdb: ...
71
66
  @overload
72
67
  @staticmethod
73
- def provider_factory(
74
- provider: Literal[ProviderType.TVDB], settings: SettingStore
75
- ) -> Tvdb: ...
76
- @overload
77
- @staticmethod
78
68
  def provider_factory(
79
69
  provider: Literal[ProviderType.TVMAZE], settings: SettingStore
80
70
  ) -> TvMaze: ...
@@ -82,17 +72,14 @@ class Provider[M: Metadata](ABC):
82
72
  @staticmethod
83
73
  def provider_factory(
84
74
  provider: ProviderType, settings: SettingStore
85
- ) -> Omdb | Tmdb | Tvdb | TvMaze: ...
75
+ ) -> Omdb | Tmdb | TvMaze: ...
86
76
  @staticmethod
87
77
  def provider_factory(
88
78
  provider: ProviderType, settings: SettingStore
89
- ) -> Omdb | Tmdb | Tvdb | TvMaze:
79
+ ) -> Omdb | Tmdb | TvMaze:
90
80
  """Factory function for DB Provider concrete classes."""
91
- provider_classes: dict[
92
- ProviderType, type[Omdb] | type[Tmdb] | type[Tvdb] | type[TvMaze]
93
- ] = {
81
+ provider_classes: dict[ProviderType, type[Omdb] | type[Tmdb] | type[TvMaze]] = {
94
82
  ProviderType.TMDB: Tmdb,
95
- ProviderType.TVDB: Tvdb,
96
83
  ProviderType.TVMAZE: TvMaze,
97
84
  ProviderType.OMDB: Omdb,
98
85
  }
@@ -250,143 +237,6 @@ class Tmdb(Provider[MetadataMovie]):
250
237
  raise MnamerNotFoundException
251
238
 
252
239
 
253
- class Tvdb(Provider[MetadataEpisode]):
254
- """Queries the TVDb API."""
255
-
256
- api_key: str = environ.get("API_KEY_TVDB", "E69C7A2CEF2F3152")
257
- token: str
258
-
259
- def __init__(self, api_key: str = "", cache: bool = True):
260
- super().__init__(api_key, cache)
261
- assert self.api_key
262
- self.token = "" if self.cache else self._login()
263
-
264
- def _login(self) -> str:
265
- return tvdb_login(self.api_key)
266
-
267
- @override
268
- def search(self, query: MetadataEpisode) -> Iterator[MetadataEpisode]:
269
- """Searches TVDb for movie metadata."""
270
- assert query
271
- if not self.token:
272
- self.token = self._login()
273
- if query.id_tvdb and query.date:
274
- results = self._search_tvdb_date(query.id_tvdb, query.date, query.language)
275
- elif query.id_tvdb:
276
- results = self._search_id(
277
- query.id_tvdb, query.season, query.episode, query.language
278
- )
279
- elif query.series and query.date:
280
- results = self._search_series_date(query.series, query.date, query.language)
281
- elif query.series:
282
- results = self._search_series(
283
- query.series, query.season, query.episode, query.language
284
- )
285
- else:
286
- raise MnamerNotFoundException
287
- yield from results
288
-
289
- def _search_id(
290
- self,
291
- id_tvdb: str,
292
- season: int | None = None,
293
- episode: int | None = None,
294
- language: Language | None = None,
295
- ) -> Iterator[MetadataEpisode]:
296
- found = False
297
- series_data = tvdb_series_id(
298
- self.token, id_tvdb, language=language, cache=self.cache
299
- )
300
- page = 1
301
- while True:
302
- episode_data = tvdb_series_id_episodes_query(
303
- self.token,
304
- id_tvdb,
305
- episode,
306
- season,
307
- language=language,
308
- page=page,
309
- cache=self.cache,
310
- )
311
- for entry in episode_data["data"]:
312
- try:
313
- yield MetadataEpisode(
314
- date=parse_date(entry["first_aired"]),
315
- episode=entry["aired_episode_number"],
316
- id_tvdb=id_tvdb,
317
- season=entry["aired_season"],
318
- series=series_data["data"]["series_name"],
319
- language=language,
320
- synopsis=(entry["overview"] or "")
321
- .replace("\r\n", "")
322
- .replace(" ", "")
323
- .strip(),
324
- title=entry["episode_name"].split(";", 1)[0],
325
- )
326
- found = True
327
- except (AttributeError, KeyError, ValueError):
328
- continue
329
- if page == episode_data["links"]["last"]:
330
- break
331
- page += 1
332
- if not found:
333
- raise MnamerNotFoundException
334
-
335
- def _search_series(
336
- self,
337
- series: str,
338
- season: int | None,
339
- episode: int | None,
340
- language: Language | None,
341
- ) -> Iterator[MetadataEpisode]:
342
- found = False
343
- series_data = tvdb_search_series(
344
- self.token, series, language=language, cache=self.cache
345
- )
346
-
347
- for series_id in [str(entry["id"]) for entry in series_data["data"][:5]]:
348
- try:
349
- for data in self._search_id(series_id, season, episode, language):
350
- if not data.series or not data.season:
351
- continue
352
- found = True
353
- yield data
354
- except MnamerNotFoundException:
355
- continue # may not have requested episode or may be banned
356
- if not found:
357
- raise MnamerNotFoundException
358
-
359
- def _search_tvdb_date(
360
- self, id_tvdb: str, release_date: dt.date, language: Language | None
361
- ) -> Iterator[MetadataEpisode]:
362
- release_date = parse_date(release_date)
363
- found = False
364
- for meta in self._search_id(id_tvdb, language=language):
365
- if meta.date and meta.date == release_date:
366
- found = True
367
- yield meta
368
- if not found:
369
- raise MnamerNotFoundException
370
-
371
- def _search_series_date(
372
- self, series: str, release_date: dt.date, language: Language | None
373
- ) -> Iterator[MetadataEpisode]:
374
- release_date = parse_date(release_date)
375
- series_data = tvdb_search_series(
376
- self.token, series, language=language, cache=self.cache
377
- )
378
- tvdb_ids = [str(entry["id"]) for entry in series_data["data"][:5]]
379
- found = False
380
- for tvdb_id in tvdb_ids:
381
- try:
382
- yield from self._search_tvdb_date(tvdb_id, release_date, language)
383
- found = True
384
- except MnamerNotFoundException:
385
- continue
386
- if not found:
387
- raise MnamerNotFoundException
388
-
389
-
390
240
  class TvMaze(Provider[MetadataEpisode]):
391
241
  """Queries the TVMaze API."""
392
242
 
@@ -398,13 +248,11 @@ class TvMaze(Provider[MetadataEpisode]):
398
248
  yield from self._lookup_with_tmaze_id_and_season_and_episode(
399
249
  query.id_tvmaze, query.season, query.episode
400
250
  )
401
- elif (query.id_tvmaze or query.id_tvdb) and query.date:
402
- yield from self._lookup_with_id_and_date(
403
- query.id_tvmaze, query.id_tvdb, query.date
404
- )
405
- elif query.id_tvmaze or query.id_tvdb:
251
+ elif query.id_tvmaze and query.date:
252
+ yield from self._lookup_with_id_and_date(query.id_tvmaze, query.date)
253
+ elif query.id_tvmaze:
406
254
  yield from self._lookup_with_id(
407
- query.id_tvmaze, query.id_tvdb, query.season, query.episode
255
+ query.id_tvmaze, query.season, query.episode
408
256
  )
409
257
  elif query.series and query.season and query.episode:
410
258
  yield from self._search_with_season_and_episode(
@@ -415,57 +263,26 @@ class TvMaze(Provider[MetadataEpisode]):
415
263
  else:
416
264
  raise MnamerNotFoundException
417
265
 
418
- @staticmethod
419
- def _opt_str(value: int | str | None) -> str | None:
420
- return str(value) if value else None
421
-
422
266
  def _lookup_with_tmaze_id_and_season_and_episode(
423
267
  self, id_tvmaze: str, season: int | None, episode: int | None
424
268
  ) -> Iterator[MetadataEpisode]:
425
269
  series_data = tvmaze_show(id_tvmaze)
426
270
  episode_data = tvmaze_episode_by_number(id_tvmaze, season, episode)
427
- id_tvdb = self._opt_str(series_data["externals"].get("thetvdb"))
428
- yield self._transform_meta(id_tvmaze, id_tvdb, series_data, episode_data)
271
+ yield self._transform_meta(id_tvmaze, series_data, episode_data)
429
272
 
430
273
  def _lookup_with_id_and_date(
431
- self, id_tvmaze: str | None, id_tvdb: str | None, air_date: dt.date
274
+ self, id_tvmaze: str, air_date: dt.date
432
275
  ) -> Iterator[MetadataEpisode]:
433
- assert id_tvmaze or id_tvdb
434
- if id_tvmaze:
435
- series_data = tvmaze_show(id_tvmaze)
436
- query_id_tvmaze = id_tvmaze
437
- query_id_tvdb = self._opt_str(series_data["externals"].get("thetvdb"))
438
- else:
439
- series_data = tvmaze_show_lookup(id_tvdb=id_tvdb)
440
- query_id_tvmaze = str(series_data["id"])
441
- query_id_tvdb = id_tvdb
442
- episode_data = tvmaze_episodes_by_date(query_id_tvmaze, air_date)
443
- for episode_entry in episode_data:
444
- yield self._transform_meta(
445
- query_id_tvmaze, query_id_tvdb, series_data, episode_entry
446
- )
276
+ series_data = tvmaze_show(id_tvmaze)
277
+ for episode_entry in tvmaze_episodes_by_date(id_tvmaze, air_date):
278
+ yield self._transform_meta(id_tvmaze, series_data, episode_entry)
447
279
 
448
280
  def _lookup_with_id(
449
- self,
450
- id_tvmaze: str | None,
451
- id_tvdb: str | None,
452
- season: int | None,
453
- episode: int | None,
281
+ self, id_tvmaze: str, season: int | None, episode: int | None
454
282
  ) -> Iterator[MetadataEpisode]:
455
- assert id_tvmaze or id_tvdb
456
- if id_tvmaze:
457
- query_id_tvmaze = id_tvmaze
458
- series_data = tvmaze_show(id_tvmaze)
459
- query_id_tvdb = self._opt_str(series_data["externals"].get("thetvdb"))
460
- else:
461
- series_data = tvmaze_show_lookup(id_tvdb=id_tvdb)
462
- query_id_tvdb = id_tvdb
463
- query_id_tvmaze = str(series_data["id"])
464
- episode_data = tvmaze_show_episodes_list(query_id_tvmaze)
465
- for episode_entry in episode_data:
466
- meta = self._transform_meta(
467
- query_id_tvmaze, query_id_tvdb, series_data, episode_entry
468
- )
283
+ series_data = tvmaze_show(id_tvmaze)
284
+ for episode_entry in tvmaze_show_episodes_list(id_tvmaze):
285
+ meta = self._transform_meta(id_tvmaze, series_data, episode_entry)
469
286
  if season is not None and season != meta.season:
470
287
  continue
471
288
  if episode is not None and episode != meta.episode:
@@ -486,7 +303,7 @@ class TvMaze(Provider[MetadataEpisode]):
486
303
  episode_entry = tvmaze_episode_by_number(id_tvmaze, season, episode)
487
304
  except MnamerNotFoundException:
488
305
  continue
489
- meta = self._transform_meta(id_tvmaze, None, series_entry, episode_entry)
306
+ meta = self._transform_meta(id_tvmaze, series_entry, episode_entry)
490
307
  if season != meta.season:
491
308
  continue
492
309
  if episode is not None and episode != meta.episode:
@@ -505,10 +322,7 @@ class TvMaze(Provider[MetadataEpisode]):
505
322
  id_tvmaze = str(series_entry["id"])
506
323
  episode_data = tvmaze_show_episodes_list(id_tvmaze)
507
324
  for episode_entry in episode_data:
508
- id_tvdb = self._opt_str(series_entry["externals"].get("thetvdb"))
509
- meta = self._transform_meta(
510
- id_tvmaze, id_tvdb, series_entry, episode_entry
511
- )
325
+ meta = self._transform_meta(id_tvmaze, series_entry, episode_entry)
512
326
  if season is not None and season != meta.season:
513
327
  continue
514
328
  if episode is not None and episode != meta.episode:
@@ -518,7 +332,6 @@ class TvMaze(Provider[MetadataEpisode]):
518
332
  @staticmethod
519
333
  def _transform_meta(
520
334
  id_tvmaze: str,
521
- id_tvdb: str | None,
522
335
  series_entry: TvMazeShow,
523
336
  episode_entry: TvMazeEpisode,
524
337
  ) -> MetadataEpisode:
@@ -526,7 +339,6 @@ class TvMaze(Provider[MetadataEpisode]):
526
339
  return MetadataEpisode(
527
340
  date=parse_date(airdate) if airdate else None,
528
341
  episode=episode_entry["number"],
529
- id_tvdb=id_tvdb or None,
530
342
  id_tvmaze=id_tvmaze or None,
531
343
  season=episode_entry["season"],
532
344
  series=series_entry["name"],
mnamer/setting_spec.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import dataclasses
2
+ from collections.abc import Callable
2
3
  from typing import Any
3
4
 
4
5
  from mnamer.types import SettingType
@@ -18,7 +19,7 @@ class SettingSpec:
18
19
  flags: list[str] | None = None
19
20
  help: str | None = None
20
21
  nargs: str | None = None
21
- typevar: type | None = None
22
+ typevar: Callable[[str], object] | None = None
22
23
 
23
24
  def as_dict(self) -> dict[str, Any]:
24
25
  """Converts ArgSpec instance into a Python dictionary."""
mnamer/setting_store.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import dataclasses
2
2
  import json
3
+ import re
3
4
  from collections.abc import Callable
4
5
  from pathlib import Path
5
6
  from typing import Any, override
@@ -14,6 +15,15 @@ from mnamer.types import MediaType, ProviderType, SettingType
14
15
  from mnamer.utils import crawl_out, json_loads, normalize_containers
15
16
 
16
17
 
18
+ def _episode_provider(value: str) -> str:
19
+ if value.lower() == "tvdb":
20
+ raise MnamerException(
21
+ "The TVDb episode provider was removed. "
22
+ "Use --episode-api=tvmaze or set episode_api to tvmaze in your config."
23
+ )
24
+ return value
25
+
26
+
17
27
  @dataclasses.dataclass
18
28
  class SettingStore:
19
29
  """
@@ -191,11 +201,12 @@ class SettingStore:
191
201
  episode_api: ProviderType | str = dataclasses.field(
192
202
  default=ProviderType.TVMAZE,
193
203
  metadata=SettingSpec(
194
- choices=[ProviderType.TVDB.value, ProviderType.TVMAZE.value],
204
+ choices=[ProviderType.TVMAZE.value],
195
205
  dest="episode_api",
196
206
  flags=["--episode_api", "--episode-api", "--episodeapi"],
197
207
  group=SettingType.PARAMETER,
198
- help="--episode-api={tvdb,*tvmaze}: set episode api provider",
208
+ help="--episode-api={tvmaze}: set episode api provider",
209
+ typevar=_episode_provider,
199
210
  ).as_dict(),
200
211
  )
201
212
  episode_directory: Path | None = dataclasses.field(
@@ -286,14 +297,6 @@ class SettingStore:
286
297
  help="--id-tmdb=<ID>: specify a TMDb movie id override",
287
298
  ).as_dict(),
288
299
  )
289
- id_tvdb: str | None = dataclasses.field(
290
- default=None,
291
- metadata=SettingSpec(
292
- flags=["--id_tvdb", "--id-tvdb", "--idtvdb"],
293
- group=SettingType.DIRECTIVE,
294
- help="--id-tvdb=<ID>: specify a TVDb series id override",
295
- ).as_dict(),
296
- )
297
300
  id_tvmaze: str | None = dataclasses.field(
298
301
  default=None,
299
302
  metadata=SettingSpec(
@@ -341,10 +344,6 @@ class SettingStore:
341
344
  default=None,
342
345
  metadata=SettingSpec(group=SettingType.CONFIGURATION).as_dict(),
343
346
  )
344
- api_key_tvdb: str | None = dataclasses.field(
345
- default=None,
346
- metadata=SettingSpec(group=SettingType.CONFIGURATION).as_dict(),
347
- )
348
347
  api_key_tvmaze: str | None = dataclasses.field(
349
348
  default=None,
350
349
  metadata=SettingSpec(group=SettingType.CONFIGURATION).as_dict(),
@@ -368,6 +367,19 @@ class SettingStore:
368
367
 
369
368
  @override
370
369
  def __setattr__(self, key: str, value: Any):
370
+ if key == "episode_api" and isinstance(value, str):
371
+ _episode_provider(value)
372
+ if key in {
373
+ "episode_format",
374
+ "episode_directory",
375
+ "movie_format",
376
+ "movie_directory",
377
+ }:
378
+ if re.search(r"{\s*id_tvdb\b", str(value)):
379
+ raise MnamerException(
380
+ f"The {{id_tvdb}} template field was removed from {key}. "
381
+ "Use {id_tvmaze} for a TVmaze series ID or remove the field."
382
+ )
371
383
  converter_map: dict[str, Callable[[Any], Any]] = {
372
384
  "episode_api": ProviderType,
373
385
  "episode_directory": Path,
@@ -428,6 +440,16 @@ class SettingStore:
428
440
  config_path = arguments.get("config_path", crawl_out(".mnamer-v2.json"))
429
441
  config = json_loads(str(config_path)) if config_path else {}
430
442
  if not self.config_ignore and not arguments.get("config_ignore"):
443
+ if "api_key_tvdb" in config:
444
+ raise MnamerException(
445
+ "The TVDb provider was removed. Remove api_key_tvdb from your config. "
446
+ "TVmaze does not require an API key."
447
+ )
448
+ if "id_tvdb" in config:
449
+ raise MnamerException(
450
+ "TVDb IDs are no longer supported. Remove id_tvdb from your config "
451
+ "and use --id-tvmaze with a TVmaze series ID."
452
+ )
431
453
  self.bulk_apply(config)
432
454
  if arguments:
433
455
  self.bulk_apply(arguments)
mnamer/target.py CHANGED
@@ -231,7 +231,7 @@ class Target:
231
231
  # self.metadata.series = f"{self.metadata.series} {year}"
232
232
 
233
233
  def _override_metadata_ids(self):
234
- id_types = {"imdb", "tmdb", "tvdb", "tvmaze"}
234
+ id_types = {"imdb", "tmdb", "tvmaze"}
235
235
  for id_type in id_types:
236
236
  attr = f"id_{id_type}"
237
237
  if not hasattr(self.metadata, attr):
mnamer/types.py CHANGED
@@ -24,7 +24,6 @@ class MessageType(Enum):
24
24
 
25
25
 
26
26
  class ProviderType(Enum):
27
- TVDB = "tvdb"
28
27
  TVMAZE = "tvmaze"
29
28
  TMDB = "tmdb"
30
29
  OMDB = "omdb"
@@ -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
@@ -0,0 +1,24 @@
1
+ mnamer/__init__.py,sha256=ZjNNbifQHIhjmUekOwc_VZQQdR289XCqqSIdjDSF5pw,344
2
+ mnamer/__main__.py,sha256=8AEEyLkBtfYQKOvrbg-XlLxEu9_0G-1-Rd657EBlnI8,913
3
+ mnamer/__version__.py,sha256=x9NsYFS0zfgEJDufZae2a65ZnAuhsVRaV_IvWpPmqpc,111
4
+ mnamer/argument.py,sha256=ckhNnzQtxndHv4B50P1tmEbJRdDHEji0Y3DiSjwdQF0,3635
5
+ mnamer/const.py,sha256=__YSxzRc8qDJqp4mlJncjiaRnKoi3wMLtGT1AVAm2mc,2035
6
+ mnamer/endpoints.py,sha256=jDdJzndV_6Hzahj-AvZjd3r4RAwZFlZMfIR403i66Bg,15083
7
+ mnamer/exceptions.py,sha256=dyTHFfJmkntafSg4glTxGAOsBgjlY3IGKWo5KUFgFp8,629
8
+ mnamer/frontends.py,sha256=XGo5FcVCy338zxwrXyTtp-pPpmeeilNrVbBYLuCojA0,6965
9
+ mnamer/language.py,sha256=IkGsdA28w5L8Z3ZhiQ6jwWt04fUUdxpDnYEV4SVVUgc,2048
10
+ mnamer/metadata.py,sha256=HHE76lUnVqFBClPpwRXby4SzXDQ0grY5lNXGNpFgTys,5808
11
+ mnamer/providers.py,sha256=0K8StSlpy_vqFjQ0DYWE8kKDsfMYyPW_5f4DldTJMOM,12489
12
+ mnamer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ mnamer/setting_spec.py,sha256=SvL8mDl2IUrhSuNxc07YgZ00Al1TvnsB5LnakjFmGGM,1335
14
+ mnamer/setting_store.py,sha256=U4YBYm7BltaaBakZ3sDLvogeLGKifZQxjiZadSk3Mgw,16844
15
+ mnamer/target.py,sha256=bf6TK9bSlJPXw9NyPQ1O7jfWg1v8DE1gdaH4kSZuMiw,11083
16
+ mnamer/tty.py,sha256=v66fiv_rq_NPayUt9QfsEx5mxPJWAF28RSKiHe6op_Q,4146
17
+ mnamer/types.py,sha256=XuooYWWKkiaw3IItKO1Lze44b4yt68Eget_VNHrrHuE,620
18
+ mnamer/utils.py,sha256=OverfGp3XWBXB7h6ukvDiB-3jPcGO1gGlGuuPRvwDvs,15657
19
+ mnamer-2.7.3.dev15.dist-info/licenses/LICENSE.txt,sha256=WxN2vPlY96aW3C_CRs4q0xOK4CxO5RTVTzf2W25hGmM,1071
20
+ mnamer-2.7.3.dev15.dist-info/METADATA,sha256=aJh6esz7qcJobG8vdcZS-bK1YXgOVs29v00wBEWyzZY,8422
21
+ mnamer-2.7.3.dev15.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
22
+ mnamer-2.7.3.dev15.dist-info/entry_points.txt,sha256=STyNAl6d-ueccO1C_WdDfjq5GlYwi788H4AENG040fI,48
23
+ mnamer-2.7.3.dev15.dist-info/top_level.txt,sha256=RER9MaloDml8ZAsXHlm6oKwvv2KgH_YWJLlOfKC1zAY,7
24
+ mnamer-2.7.3.dev15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (83.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,26 +0,0 @@
1
- mnamer/__init__.py,sha256=ZjNNbifQHIhjmUekOwc_VZQQdR289XCqqSIdjDSF5pw,344
2
- mnamer/__main__.py,sha256=8AEEyLkBtfYQKOvrbg-XlLxEu9_0G-1-Rd657EBlnI8,913
3
- mnamer/__version__.py,sha256=Qiqr0cHXfz2XiyzsDCr5iSvc3Fmo5huw0ayCgDtrs10,111
4
- mnamer/argument.py,sha256=PicJzTRGmamHeSKCWwhNMuf5WBSso8AbuPoZ3yOwcI4,3293
5
- mnamer/const.py,sha256=__YSxzRc8qDJqp4mlJncjiaRnKoi3wMLtGT1AVAm2mc,2035
6
- mnamer/endpoints.py,sha256=Lt5LUT-wFd2bpa-zPt_7_g5okKe4B9dR9hlwrdkzWyk,22857
7
- mnamer/exceptions.py,sha256=dyTHFfJmkntafSg4glTxGAOsBgjlY3IGKWo5KUFgFp8,629
8
- mnamer/frontends.py,sha256=XGo5FcVCy338zxwrXyTtp-pPpmeeilNrVbBYLuCojA0,6965
9
- mnamer/language.py,sha256=5pdZGmfw1Zv2DfZCK64LPFThOE1iIcmrhaJGIDVgByo,2707
10
- mnamer/metadata.py,sha256=Z3BhX-oKpwoStMkH62Zh9WCRcFTl7S3TJTPpsT-IQaw,5839
11
- mnamer/providers.py,sha256=VJYfDWf4iDYjSXs-eINfIJ6tZGhEpNSCl9wHmLi0pLE,19274
12
- mnamer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- mnamer/setting_spec.py,sha256=37V7iT0_6XJdeqD6rItqQmYG-fQYQSglPX01KRls0KQ,1279
14
- mnamer/setting_store.py,sha256=BcnUuNn823RHpOLpWvr7gVlrHZJWfxDaNfDDNqYjcqI,15977
15
- mnamer/target.py,sha256=RzvtzDabkRjw2Ygzi94FwwKrjAW22RmcYJRkrPpT7c4,11091
16
- mnamer/tty.py,sha256=v66fiv_rq_NPayUt9QfsEx5mxPJWAF28RSKiHe6op_Q,4146
17
- mnamer/types.py,sha256=aYMfEcBmPhrkA9PNrtr8JrDuBXeUNN8dbmd4T5rvRjg,638
18
- mnamer/utils.py,sha256=OverfGp3XWBXB7h6ukvDiB-3jPcGO1gGlGuuPRvwDvs,15657
19
- mnamer-2.7.3.dev13.dist-info/licenses/LICENSE.txt,sha256=WxN2vPlY96aW3C_CRs4q0xOK4CxO5RTVTzf2W25hGmM,1071
20
- mnamer-2.7.3.dev13.dist-info/METADATA,sha256=qn20M0TYjGKKmh3hwfwLENctwYI2cfmGJESqKULRceU,8039
21
- mnamer-2.7.3.dev13.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
22
- mnamer-2.7.3.dev13.dist-info/entry_points.txt,sha256=STyNAl6d-ueccO1C_WdDfjq5GlYwi788H4AENG040fI,48
23
- mnamer-2.7.3.dev13.dist-info/scm_file_list.json,sha256=5i5CfzLkoDtbNFDpDbtUYr29wEFSoSYH77232K0zgQw,2174
24
- mnamer-2.7.3.dev13.dist-info/scm_version.json,sha256=A6yTCH6aBT-H4fOoON-_YR6PvpuSLiXHSH5h55pYLMc,161
25
- mnamer-2.7.3.dev13.dist-info/top_level.txt,sha256=RER9MaloDml8ZAsXHlm6oKwvv2KgH_YWJLlOfKC1zAY,7
26
- mnamer-2.7.3.dev13.dist-info/RECORD,,
@@ -1,76 +0,0 @@
1
- {
2
- "files": [
3
- "README.md",
4
- "uv.lock",
5
- "Dockerfile",
6
- ".python-version",
7
- "LICENSE.txt",
8
- "pyproject.toml",
9
- "AGENTS.md",
10
- ".dockerignore",
11
- "CLAUDE.md",
12
- "MANIFEST.in",
13
- "makefile",
14
- ".gitignore",
15
- "pytest.ini",
16
- ".vscode/settings.json",
17
- "assets/logo.png",
18
- "assets/logo-2.png",
19
- "assets/design.eps",
20
- "assets/recording.mov",
21
- "assets/screenshot.png",
22
- "assets/screenshot.eps",
23
- "assets/logo-3.png",
24
- "mnamer/py.typed",
25
- "mnamer/__init__.py",
26
- "mnamer/const.py",
27
- "mnamer/exceptions.py",
28
- "mnamer/endpoints.py",
29
- "mnamer/providers.py",
30
- "mnamer/target.py",
31
- "mnamer/utils.py",
32
- "mnamer/language.py",
33
- "mnamer/argument.py",
34
- "mnamer/metadata.py",
35
- "mnamer/setting_store.py",
36
- "mnamer/tty.py",
37
- "mnamer/frontends.py",
38
- "mnamer/setting_spec.py",
39
- "mnamer/__main__.py",
40
- "mnamer/types.py",
41
- "tests/__init__.py",
42
- "tests/conftest.py",
43
- "tests/e2e/test_moving.py",
44
- "tests/e2e/__init__.py",
45
- "tests/e2e/test_directives.py",
46
- "tests/e2e/conftest.py",
47
- "tests/e2e/test_errors.py",
48
- "tests/network/test_endpoints__tvmaze.py",
49
- "tests/network/test_providers__tvmaze.py",
50
- "tests/network/test_providers__tvdb.py",
51
- "tests/network/test_providers__tmdb.py",
52
- "tests/network/__init__.py",
53
- "tests/network/test_endpoints__omdb.py",
54
- "tests/network/test_endpoints__tvdb.py",
55
- "tests/network/test_providers__omdb.py",
56
- "tests/network/test_endpoints__tmdb.py",
57
- "tests/local/__init__.py",
58
- "tests/local/test_argument.py",
59
- "tests/local/test_utils.py",
60
- "tests/local/test_tty.py",
61
- "tests/local/test_target.py",
62
- "tests/local/test_setting_spec.py",
63
- "tests/local/test_setting_store.py",
64
- "tests/local/test_providers.py",
65
- "tests/local/test_language.py",
66
- "tests/local/test_metadata.py",
67
- ".github/dependabot.yml",
68
- ".github/actions/lint/action.yml",
69
- ".github/actions/init/action.yml",
70
- ".github/actions/test/action.yml",
71
- ".github/workflows/push.yml",
72
- ".github/workflows/publish-docker.yml",
73
- ".github/workflows/publish.yml",
74
- ".github/workflows/pull_request.yml"
75
- ]
76
- }
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "2.7.2",
3
- "distance": 13,
4
- "node": "g45f4229ad8a47a05dedcdcf4bcdb78796f1c4d4d",
5
- "dirty": false,
6
- "branch": "main",
7
- "node_date": "2026-07-11"
8
- }