mkv-episode-matcher 0.4.0__py3-none-any.whl → 0.4.5__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.

Potentially problematic release.


This version of mkv-episode-matcher might be problematic. Click here for more details.

@@ -1 +1,9 @@
1
+ """MKV Episode Matcher package."""
2
+ from importlib.metadata import version, PackageNotFoundError
3
+
4
+ try:
5
+ __version__ = version("mkv-episode-matcher")
6
+ except PackageNotFoundError:
7
+ # package is not installed
8
+ __version__ = "unknown"
1
9
 
@@ -1,9 +1,10 @@
1
1
  # __main__.py
2
2
  import argparse
3
3
  import os
4
+ import sys
4
5
 
5
6
  from loguru import logger
6
-
7
+ from mkv_episode_matcher import __version__
7
8
  from mkv_episode_matcher.config import get_config, set_config
8
9
 
9
10
  # Log the start of the application
@@ -62,6 +63,12 @@ def main():
62
63
 
63
64
  # Parse command-line arguments
64
65
  parser = argparse.ArgumentParser(description="Process shows with TMDb API")
66
+ parser.add_argument(
67
+ "--version",
68
+ action="version",
69
+ version=f"%(prog)s {__version__}",
70
+ help="Show the version number and exit"
71
+ )
65
72
  parser.add_argument("--tmdb-api-key", help="TMDb API key")
66
73
  parser.add_argument("--show-dir", help="Main directory of the show")
67
74
  parser.add_argument(
@@ -105,71 +112,49 @@ def main():
105
112
  check_gpu_support()
106
113
  return
107
114
  logger.debug(f"Command-line arguments: {args}")
108
- open_subtitles_api_key = ""
109
- open_subtitles_user_agent = ""
110
- open_subtitles_username = ""
111
- open_subtitles_password = ""
112
- # Check if API key is provided via command-line argument
113
- tmdb_api_key = args.tmdb_api_key
114
-
115
- # If API key is not provided, try to get it from the cache
116
- if not tmdb_api_key:
117
- cached_config = get_config(CONFIG_FILE)
118
- if cached_config:
119
- tmdb_api_key = cached_config.get("tmdb_api_key")
120
115
 
121
- # If API key is still not available, prompt the user to input it
116
+ # Load configuration once
117
+ config = get_config(CONFIG_FILE)
118
+
119
+ # Get TMDb API key
120
+ tmdb_api_key = args.tmdb_api_key or config.get("tmdb_api_key")
122
121
  if not tmdb_api_key:
123
122
  tmdb_api_key = input("Enter your TMDb API key: ")
124
- # Cache the API key
125
-
126
123
  logger.debug(f"TMDb API Key: {tmdb_api_key}")
124
+
127
125
  logger.debug("Getting OpenSubtitles API key")
128
- cached_config = get_config(CONFIG_FILE)
129
- try:
130
- open_subtitles_api_key = cached_config.get("open_subtitles_api_key")
131
- open_subtitles_user_agent = cached_config.get("open_subtitles_user_agent")
132
- open_subtitles_username = cached_config.get("open_subtitles_username")
133
- open_subtitles_password = cached_config.get("open_subtitles_password")
134
- except:
135
- pass
126
+ open_subtitles_api_key = config.get("open_subtitles_api_key")
127
+ open_subtitles_user_agent = config.get("open_subtitles_user_agent")
128
+ open_subtitles_username = config.get("open_subtitles_username")
129
+ open_subtitles_password = config.get("open_subtitles_password")
130
+
136
131
  if args.get_subs:
137
132
  if not open_subtitles_api_key:
138
133
  open_subtitles_api_key = input("Enter your OpenSubtitles API key: ")
139
-
140
134
  if not open_subtitles_user_agent:
141
135
  open_subtitles_user_agent = input("Enter your OpenSubtitles User Agent: ")
142
-
143
136
  if not open_subtitles_username:
144
137
  open_subtitles_username = input("Enter your OpenSubtitles Username: ")
145
-
146
138
  if not open_subtitles_password:
147
139
  open_subtitles_password = input("Enter your OpenSubtitles Password: ")
148
-
149
- # If show directory is provided via command-line argument, use it
150
- show_dir = args.show_dir
140
+
141
+ # Use config for show directory and tesseract path
142
+ show_dir = args.show_dir or config.get("show_dir")
143
+ if not show_dir:
144
+ show_dir = input("Enter the main directory of the show:")
145
+ logger.info(f"Show Directory: {show_dir}")
151
146
  if not show_dir:
152
- show_dir = cached_config.get("show_dir")
153
- if not show_dir:
154
- # If show directory is not provided, prompt the user to input it
155
- show_dir = input("Enter the main directory of the show:")
156
- logger.info(f"Show Directory: {show_dir}")
157
- # if the user does not provide a show directory, make the default show directory the current working directory
158
- if not show_dir:
159
- show_dir = os.getcwd()
147
+ show_dir = os.getcwd()
148
+
160
149
  if not args.tesseract_path:
161
- tesseract_path = cached_config.get("tesseract_path")
162
-
150
+ tesseract_path = config.get("tesseract_path")
163
151
  if not tesseract_path:
164
- tesseract_path = input(
165
- r"Enter the path to the tesseract executable: ['C:\Program Files\Tesseract-OCR\tesseract.exe']"
166
- )
167
-
152
+ tesseract_path = input(r"Enter the path to the tesseract executable: ['C:\Program Files\Tesseract-OCR\tesseract.exe']")
168
153
  else:
169
154
  tesseract_path = args.tesseract_path
170
155
  logger.debug(f"Teesseract Path: {tesseract_path}")
171
156
  logger.debug(f"Show Directory: {show_dir}")
172
-
157
+
173
158
  # Set the configuration
174
159
  set_config(
175
160
  tmdb_api_key,
@@ -32,7 +32,7 @@ def process_show(season=None, dry_run=False, get_subs=False):
32
32
  # Early check for reference files
33
33
  reference_dir = Path(CACHE_DIR) / "data" / show_name
34
34
  reference_files = list(reference_dir.glob("*.srt"))
35
- if not reference_files:
35
+ if (not get_subs) and (not reference_files):
36
36
  logger.error(f"No reference subtitle files found in {reference_dir}")
37
37
  logger.info("Please download reference subtitles first")
38
38
  return
@@ -67,7 +67,7 @@ def process_show(season=None, dry_run=False, get_subs=False):
67
67
  if get_subs:
68
68
  show_id = fetch_show_id(matcher.show_name)
69
69
  if show_id:
70
- get_subtitles(show_id, seasons={season_num})
70
+ get_subtitles(show_id, seasons={season_num}, config=config)
71
71
 
72
72
  unmatched_files = []
73
73
  for mkv_file in mkv_files:
@@ -105,4 +105,4 @@ def process_show(season=None, dry_run=False, get_subs=False):
105
105
  finally:
106
106
  if not dry_run:
107
107
  shutil.rmtree(temp_dir)
108
- cleanup_ocr_files(show_dir)
108
+ cleanup_ocr_files(show_dir)
@@ -121,16 +121,17 @@ def rename_episode_file(original_file_path, new_filename):
121
121
  logger.error(f"Failed to rename file: {e}")
122
122
  return None
123
123
 
124
- def get_subtitles(show_id, seasons: set[int]):
124
+ def get_subtitles(show_id, seasons: set[int], config=None):
125
125
  """
126
126
  Retrieves and saves subtitles for a given TV show and seasons.
127
127
 
128
128
  Args:
129
129
  show_id (int): The ID of the TV show.
130
130
  seasons (Set[int]): A set of season numbers for which subtitles should be retrieved.
131
+ config (Config object, optional): Preloaded configuration.
131
132
  """
132
- logger.info(f"Getting subtitles for show ID {show_id}")
133
- config = get_config(CONFIG_FILE)
133
+ if config is None:
134
+ config = get_config(CONFIG_FILE)
134
135
  show_dir = config.get("show_dir")
135
136
  series_name = sanitize_filename(os.path.basename(show_dir))
136
137
  tmdb_api_key = config.get("tmdb_api_key")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkv-episode-matcher
3
- Version: 0.4.0
3
+ Version: 0.4.5
4
4
  Summary: The MKV Episode Matcher is a tool for identifying TV series episodes from MKV files and renaming the files accordingly.
5
5
  Home-page: https://github.com/Jsakkos/mkv-episode-matcher
6
6
  Author: Jonathan Sakkos
@@ -67,7 +67,7 @@ Automatically match and rename your MKV TV episodes using The Movie Database (TM
67
67
  - Python 3.9 or higher
68
68
  - [FFmpeg](https://ffmpeg.org/download.html) installed and available in system PATH
69
69
  - [Tesseract OCR](https://github.com/UB-Mannheim/tesseract/wiki) installed (required for image-based subtitle processing)
70
- - TMDb API key
70
+ - TMDb API key (optional, for subtitle downloads)
71
71
  - OpenSubtitles account (optional, for subtitle downloads)
72
72
 
73
73
  ## Quick Start
@@ -83,10 +83,6 @@ pip install mkv-episode-matcher
83
83
  mkv-match --show-dir "path/to/your/show"
84
84
  ```
85
85
 
86
- ## Documentation
87
-
88
- Full documentation is available at [https://jsakkos.github.io/mkv-episode-matcher/](https://jsakkos.github.io/mkv-episode-matcher/)
89
-
90
86
  ## Directory Structure
91
87
 
92
88
  MKV Episode Matcher expects your TV shows to be organized as follows:
@@ -136,3 +132,6 @@ Distributed under the MIT License. See `LICENSE` for more information.
136
132
  - [OpenSubtitles](https://www.opensubtitles.com/) for subtitle integration
137
133
  - All contributors who have helped improve this project
138
134
 
135
+ ## Documentation
136
+
137
+ Full documentation is available at [https://jsakkos.github.io/mkv-episode-matcher/](https://jsakkos.github.io/mkv-episode-matcher/)
@@ -1,14 +1,14 @@
1
1
  mkv_episode_matcher/.gitattributes,sha256=Gh2-F2vCM7SZ01pX23UT8pQcmauXWfF3gwyRSb6ZAFs,66
2
- mkv_episode_matcher/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
- mkv_episode_matcher/__main__.py,sha256=Tpppeh59E2PKCrALweBdfzrm4GUeK8FjAECz2ECvmXs,7105
2
+ mkv_episode_matcher/__init__.py,sha256=aNlpgTo1kHVrBcR3SH6wRmCgKu8KjNTki1ZvFfAud6s,240
3
+ mkv_episode_matcher/__main__.py,sha256=NJdbYc5ht52uSw7PSO4EvJ2EbrrQqv1N9YhpUcZPH-Q,6517
4
4
  mkv_episode_matcher/config.py,sha256=zDDKBcsDt5fME9BRqiTi7yWKeast1pZh36BNYMvIBYM,2419
5
5
  mkv_episode_matcher/episode_identification.py,sha256=_6M1UJkq1RGfmLI32u9dNOVvgp5Vf2MjqW2MTx0Gl8E,10329
6
- mkv_episode_matcher/episode_matcher.py,sha256=vunYpHQxyXo3l88BUScXa7_kMYMCV1pXpQxaLa-plZA,4325
6
+ mkv_episode_matcher/episode_matcher.py,sha256=4pSFr7MDDdjqCFlKMkn8qGTjT_Xw6Abd4mN8YS94yVw,4362
7
7
  mkv_episode_matcher/mkv_to_srt.py,sha256=4yxBHRVhgVby0UtQ2aTXGuoQpid8pkgjMIaHU6GCdzc,10857
8
8
  mkv_episode_matcher/speech_to_text.py,sha256=wVDrFFR7oASGMyq5cfOWmInEIeU9b3MPCLs9EyJrOMw,3128
9
9
  mkv_episode_matcher/subtitle_utils.py,sha256=rYSbd393pKYQW0w4sXgals02WFGqMYYYkQHDbEkWF8c,2666
10
10
  mkv_episode_matcher/tmdb_client.py,sha256=LbMCgjmp7sCbrQo_CDlpcnryKPz5S7inE24YY9Pyjk4,4172
11
- mkv_episode_matcher/utils.py,sha256=VASbougN3rb2iu40iZWkGjKIbahW713TOrFBo_TR9wo,14269
11
+ mkv_episode_matcher/utils.py,sha256=OkOwAjLB0yI3XYzQx5HONywxL4F9OenfQJR97SI8QAM,14316
12
12
  mkv_episode_matcher/libraries/pgs2srt/.gitignore,sha256=mt3uxWYZaFurMw_yGE258gWhtGKPVR7e3Ll4ALJpyj4,23
13
13
  mkv_episode_matcher/libraries/pgs2srt/README.md,sha256=olb25G17tj0kxPgp_LcH5I2QWXjgP1m8JFyjYRGz4UU,1374
14
14
  mkv_episode_matcher/libraries/pgs2srt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -19,8 +19,8 @@ mkv_episode_matcher/libraries/pgs2srt/requirements.txt,sha256=sg87dqWw_qpbwciw-M
19
19
  mkv_episode_matcher/libraries/pgs2srt/Libraries/SubZero/SubZero.py,sha256=geT1LXdVd8yED9zoJ9K1XfP2JzGcM7u1SslHYrJI09o,10061
20
20
  mkv_episode_matcher/libraries/pgs2srt/Libraries/SubZero/post_processing.py,sha256=GKtVy_Lxv-z27mkRG8pJF2znKWXwZTot7jL6kN-zIxM,10503
21
21
  mkv_episode_matcher/libraries/pgs2srt/Libraries/SubZero/dictionaries/data.py,sha256=AlJHUYXl85J95OzGRik-AHVfzDd7Q8BJCvD4Nr8kRIk,938598
22
- mkv_episode_matcher-0.4.0.dist-info/METADATA,sha256=o6xssGRpkRcr9elsAt0lf2ktwr2-7aSVweBZUDtlr7I,5545
23
- mkv_episode_matcher-0.4.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
24
- mkv_episode_matcher-0.4.0.dist-info/entry_points.txt,sha256=IglJ43SuCZq2eQ3shMFILCkmQASJHnDCI3ogohW2Hn4,64
25
- mkv_episode_matcher-0.4.0.dist-info/top_level.txt,sha256=XRLbd93HUaedeWLtkyTvQjFcE5QcBRYa3V-CfHrq-OI,20
26
- mkv_episode_matcher-0.4.0.dist-info/RECORD,,
22
+ mkv_episode_matcher-0.4.5.dist-info/METADATA,sha256=iUd6UImRy4goGJSgJcZVDk0oCjCz3rfsi3DkO9PG2pU,5579
23
+ mkv_episode_matcher-0.4.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
24
+ mkv_episode_matcher-0.4.5.dist-info/entry_points.txt,sha256=IglJ43SuCZq2eQ3shMFILCkmQASJHnDCI3ogohW2Hn4,64
25
+ mkv_episode_matcher-0.4.5.dist-info/top_level.txt,sha256=XRLbd93HUaedeWLtkyTvQjFcE5QcBRYa3V-CfHrq-OI,20
26
+ mkv_episode_matcher-0.4.5.dist-info/RECORD,,