mkv-episode-matcher 0.4.1__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.

@@ -112,71 +112,49 @@ def main():
112
112
  check_gpu_support()
113
113
  return
114
114
  logger.debug(f"Command-line arguments: {args}")
115
- open_subtitles_api_key = ""
116
- open_subtitles_user_agent = ""
117
- open_subtitles_username = ""
118
- open_subtitles_password = ""
119
- # Check if API key is provided via command-line argument
120
- tmdb_api_key = args.tmdb_api_key
121
-
122
- # If API key is not provided, try to get it from the cache
123
- if not tmdb_api_key:
124
- cached_config = get_config(CONFIG_FILE)
125
- if cached_config:
126
- tmdb_api_key = cached_config.get("tmdb_api_key")
127
115
 
128
- # 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")
129
121
  if not tmdb_api_key:
130
122
  tmdb_api_key = input("Enter your TMDb API key: ")
131
- # Cache the API key
132
-
133
123
  logger.debug(f"TMDb API Key: {tmdb_api_key}")
124
+
134
125
  logger.debug("Getting OpenSubtitles API key")
135
- cached_config = get_config(CONFIG_FILE)
136
- try:
137
- open_subtitles_api_key = cached_config.get("open_subtitles_api_key")
138
- open_subtitles_user_agent = cached_config.get("open_subtitles_user_agent")
139
- open_subtitles_username = cached_config.get("open_subtitles_username")
140
- open_subtitles_password = cached_config.get("open_subtitles_password")
141
- except:
142
- 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
+
143
131
  if args.get_subs:
144
132
  if not open_subtitles_api_key:
145
133
  open_subtitles_api_key = input("Enter your OpenSubtitles API key: ")
146
-
147
134
  if not open_subtitles_user_agent:
148
135
  open_subtitles_user_agent = input("Enter your OpenSubtitles User Agent: ")
149
-
150
136
  if not open_subtitles_username:
151
137
  open_subtitles_username = input("Enter your OpenSubtitles Username: ")
152
-
153
138
  if not open_subtitles_password:
154
139
  open_subtitles_password = input("Enter your OpenSubtitles Password: ")
155
-
156
- # If show directory is provided via command-line argument, use it
157
- 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}")
158
146
  if not show_dir:
159
- show_dir = cached_config.get("show_dir")
160
- if not show_dir:
161
- # If show directory is not provided, prompt the user to input it
162
- show_dir = input("Enter the main directory of the show:")
163
- logger.info(f"Show Directory: {show_dir}")
164
- # if the user does not provide a show directory, make the default show directory the current working directory
165
- if not show_dir:
166
- show_dir = os.getcwd()
147
+ show_dir = os.getcwd()
148
+
167
149
  if not args.tesseract_path:
168
- tesseract_path = cached_config.get("tesseract_path")
169
-
150
+ tesseract_path = config.get("tesseract_path")
170
151
  if not tesseract_path:
171
- tesseract_path = input(
172
- r"Enter the path to the tesseract executable: ['C:\Program Files\Tesseract-OCR\tesseract.exe']"
173
- )
174
-
152
+ tesseract_path = input(r"Enter the path to the tesseract executable: ['C:\Program Files\Tesseract-OCR\tesseract.exe']")
175
153
  else:
176
154
  tesseract_path = args.tesseract_path
177
155
  logger.debug(f"Teesseract Path: {tesseract_path}")
178
156
  logger.debug(f"Show Directory: {show_dir}")
179
-
157
+
180
158
  # Set the configuration
181
159
  set_config(
182
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.1
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
@@ -1,14 +1,14 @@
1
1
  mkv_episode_matcher/.gitattributes,sha256=Gh2-F2vCM7SZ01pX23UT8pQcmauXWfF3gwyRSb6ZAFs,66
2
2
  mkv_episode_matcher/__init__.py,sha256=aNlpgTo1kHVrBcR3SH6wRmCgKu8KjNTki1ZvFfAud6s,240
3
- mkv_episode_matcher/__main__.py,sha256=0ZwFXw30744lZ8HIMzUN4F2abpTRCT4glBCM9XQdD3k,7328
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.1.dist-info/METADATA,sha256=IWKnIxGcG_W1EEtPfYasyMCfyZL7-NL_ScYfNl0HVlg,5579
23
- mkv_episode_matcher-0.4.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
24
- mkv_episode_matcher-0.4.1.dist-info/entry_points.txt,sha256=IglJ43SuCZq2eQ3shMFILCkmQASJHnDCI3ogohW2Hn4,64
25
- mkv_episode_matcher-0.4.1.dist-info/top_level.txt,sha256=XRLbd93HUaedeWLtkyTvQjFcE5QcBRYa3V-CfHrq-OI,20
26
- mkv_episode_matcher-0.4.1.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,,