TonieToolbox 0.1.0__py3-none-any.whl → 0.1.2__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.
TonieToolbox/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
2
  TonieToolbox - Convert audio files to Tonie box compatible format
3
3
  """
4
4
 
5
- __version__ = '0.1.0'
5
+ __version__ = '0.1.2'
TonieToolbox/__main__.py CHANGED
@@ -71,17 +71,17 @@ def main():
71
71
 
72
72
  ffmpeg_binary = args.ffmpeg
73
73
  if ffmpeg_binary is None:
74
- ffmpeg_binary = get_ffmpeg_binary()
74
+ ffmpeg_binary = get_ffmpeg_binary(args.auto_download)
75
75
  if ffmpeg_binary is None:
76
- logger.error("Could not find FFmpeg. Please install FFmpeg or specify its location using --ffmpeg")
76
+ logger.error("Could not find FFmpeg. Please install FFmpeg or specify its location using --ffmpeg or use --auto-download")
77
77
  sys.exit(1)
78
78
  logger.debug("Using FFmpeg binary: %s", ffmpeg_binary)
79
79
 
80
80
  opus_binary = args.opusenc
81
81
  if opus_binary is None:
82
- opus_binary = get_opus_binary()
82
+ opus_binary = get_opus_binary(args.auto_download)
83
83
  if opus_binary is None:
84
- logger.error("Could not find opusenc. Please install opus-tools or specify its location using --opusenc")
84
+ logger.error("Could not find opusenc. Please install opus-tools or specify its location using --opusenc or use --auto-download")
85
85
  sys.exit(1)
86
86
  logger.debug("Using opusenc binary: %s", opus_binary)
87
87
 
@@ -123,7 +123,7 @@ def main():
123
123
  logger.debug("Using default output location: %s", out_filename)
124
124
 
125
125
  if args.append_tonie_tag:
126
- # Validate that the value is an 8-character hex value
126
+ logger.debug("Appending Tonie tag to output filename")
127
127
  hex_tag = args.append_tonie_tag
128
128
  logger.debug("Validating tag: %s", hex_tag)
129
129
  if not all(c in '0123456789abcdefABCDEF' for c in hex_tag) or len(hex_tag) != 8:
@@ -137,7 +137,7 @@ def main():
137
137
 
138
138
  logger.info("Creating Tonie file: %s with %d input file(s)", out_filename, len(files))
139
139
  create_tonie_file(out_filename, files, args.no_tonie_header, args.user_timestamp,
140
- args.bitrate, not args.cbr, ffmpeg_binary, opus_binary, args.keep_temp)
140
+ args.bitrate, not args.cbr, ffmpeg_binary, opus_binary, args.keep_temp, args.auto_download)
141
141
  logger.info("Successfully created Tonie file: %s", out_filename)
142
142
 
143
143
 
@@ -12,7 +12,7 @@ from .logger import get_logger
12
12
  logger = get_logger('audio_conversion')
13
13
 
14
14
 
15
- def get_opus_tempfile(ffmpeg_binary=None, opus_binary=None, filename=None, bitrate=48, vbr=True, keep_temp=False):
15
+ def get_opus_tempfile(ffmpeg_binary=None, opus_binary=None, filename=None, bitrate=48, vbr=True, keep_temp=False, auto_download=False):
16
16
  """
17
17
  Convert an audio file to Opus format and return a temporary file handle.
18
18
 
@@ -23,6 +23,7 @@ def get_opus_tempfile(ffmpeg_binary=None, opus_binary=None, filename=None, bitra
23
23
  bitrate: Bitrate for the Opus encoding in kbps
24
24
  vbr: Whether to use variable bitrate encoding
25
25
  keep_temp: Whether to keep the temporary files for testing
26
+ auto_download: Whether to automatically download dependencies if not found
26
27
 
27
28
  Returns:
28
29
  tuple: (file handle, temp_file_path) or (file handle, None) if keep_temp is False
@@ -31,18 +32,18 @@ def get_opus_tempfile(ffmpeg_binary=None, opus_binary=None, filename=None, bitra
31
32
 
32
33
  if ffmpeg_binary is None:
33
34
  logger.debug("FFmpeg not specified, attempting to auto-detect")
34
- ffmpeg_binary = get_ffmpeg_binary()
35
+ ffmpeg_binary = get_ffmpeg_binary(auto_download)
35
36
  if ffmpeg_binary is None:
36
- logger.error("Could not find or download FFmpeg binary")
37
- raise RuntimeError("Could not find or download FFmpeg binary")
37
+ logger.error("Could not find FFmpeg binary. Use --auto-download to enable automatic installation")
38
+ raise RuntimeError("Could not find FFmpeg binary. Use --auto-download to enable automatic installation")
38
39
  logger.debug("Found FFmpeg at: %s", ffmpeg_binary)
39
40
 
40
41
  if opus_binary is None:
41
42
  logger.debug("Opusenc not specified, attempting to auto-detect")
42
- opus_binary = get_opus_binary()
43
+ opus_binary = get_opus_binary(auto_download)
43
44
  if opus_binary is None:
44
- logger.error("Could not find or download Opus binary")
45
- raise RuntimeError("Could not find or download Opus binary")
45
+ logger.error("Could not find Opus binary. Use --auto-download to enable automatic installation")
46
+ raise RuntimeError("Could not find Opus binary. Use --auto-download to enable automatic installation")
46
47
  logger.debug("Found opusenc at: %s", opus_binary)
47
48
 
48
49
  vbr_parameter = "--vbr" if vbr else "--hard-cbr"
@@ -21,12 +21,12 @@ logger = get_logger('dependency_manager')
21
21
  DEPENDENCIES = {
22
22
  'ffmpeg': {
23
23
  'windows': {
24
- 'url': 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip',
24
+ 'url': 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip',
25
25
  'bin_path': 'bin/ffmpeg.exe',
26
26
  'extract_dir': 'ffmpeg'
27
27
  },
28
28
  'linux': {
29
- 'url': 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl-shared.tar.xz',
29
+ 'url': 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz',
30
30
  'bin_path': 'ffmpeg',
31
31
  'extract_dir': 'ffmpeg'
32
32
  },
@@ -280,12 +280,13 @@ def install_package(package_name):
280
280
  logger.error("Failed to install %s: %s", package_name, e)
281
281
  return False
282
282
 
283
- def ensure_dependency(dependency_name):
283
+ def ensure_dependency(dependency_name, auto_download=False):
284
284
  """
285
285
  Ensure that a dependency is available, downloading it if necessary.
286
286
 
287
287
  Args:
288
288
  dependency_name (str): Name of the dependency ('ffmpeg' or 'opusenc')
289
+ auto_download (bool): Whether to automatically download or install the dependency if not found
289
290
 
290
291
  Returns:
291
292
  str: Path to the binary if available, None otherwise
@@ -308,6 +309,11 @@ def ensure_dependency(dependency_name):
308
309
  logger.info("Found %s in PATH: %s", dependency_name, path_binary)
309
310
  return path_binary
310
311
 
312
+ # If auto_download is not enabled, don't try to install or download
313
+ if not auto_download:
314
+ logger.warning("%s not found in PATH and auto-download is disabled. Use --auto-download to enable automatic installation.", dependency_name)
315
+ return None
316
+
311
317
  # If not in PATH, check if we should install via package manager
312
318
  if 'package' in DEPENDENCIES[dependency_name].get(system, {}):
313
319
  package_name = DEPENDENCIES[dependency_name][system]['package']
@@ -359,20 +365,26 @@ def ensure_dependency(dependency_name):
359
365
  logger.error("Failed to set up %s", dependency_name)
360
366
  return None
361
367
 
362
- def get_ffmpeg_binary():
368
+ def get_ffmpeg_binary(auto_download=False):
363
369
  """
364
370
  Get the path to the FFmpeg binary, downloading it if necessary.
365
371
 
372
+ Args:
373
+ auto_download (bool): Whether to automatically download or install if not found
374
+
366
375
  Returns:
367
376
  str: Path to the FFmpeg binary if available, None otherwise
368
377
  """
369
- return ensure_dependency('ffmpeg')
378
+ return ensure_dependency('ffmpeg', auto_download)
370
379
 
371
- def get_opus_binary():
380
+ def get_opus_binary(auto_download=False):
372
381
  """
373
382
  Get the path to the opusenc binary, downloading it if necessary.
374
383
 
384
+ Args:
385
+ auto_download (bool): Whether to automatically download or install if not found
386
+
375
387
  Returns:
376
388
  str: Path to the opusenc binary if available, None otherwise
377
389
  """
378
- return ensure_dependency('opusenc')
390
+ return ensure_dependency('opusenc', auto_download)
@@ -277,7 +277,7 @@ def fix_tonie_header(out_file, chapters, timestamp, sha):
277
277
 
278
278
 
279
279
  def create_tonie_file(output_file, input_files, no_tonie_header=False, user_timestamp=None,
280
- bitrate=96, vbr=True, ffmpeg_binary=None, opus_binary=None, keep_temp=False):
280
+ bitrate=96, vbr=True, ffmpeg_binary=None, opus_binary=None, keep_temp=False, auto_download=False):
281
281
  """
282
282
  Create a Tonie file from input files.
283
283
 
@@ -291,6 +291,7 @@ def create_tonie_file(output_file, input_files, no_tonie_header=False, user_time
291
291
  ffmpeg_binary: Path to ffmpeg binary
292
292
  opus_binary: Path to opusenc binary
293
293
  keep_temp: Whether to keep temporary opus files for testing
294
+ auto_download: Whether to automatically download dependencies if not found
294
295
  """
295
296
  from .audio_conversion import get_opus_tempfile
296
297
 
@@ -360,7 +361,7 @@ def create_tonie_file(output_file, input_files, no_tonie_header=False, user_time
360
361
  else:
361
362
  logger.debug("Converting %s to Opus format (bitrate: %d kbps, VBR: %s)",
362
363
  fname, bitrate, vbr)
363
- handle, temp_file_path = get_opus_tempfile(ffmpeg_binary, opus_binary, fname, bitrate, vbr, keep_temp)
364
+ handle, temp_file_path = get_opus_tempfile(ffmpeg_binary, opus_binary, fname, bitrate, vbr, keep_temp, auto_download)
364
365
  if temp_file_path:
365
366
  temp_files.append(temp_file_path)
366
367
  logger.debug("Temporary opus file saved to: %s", temp_file_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TonieToolbox
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Convert audio files to Tonie box compatible format
5
5
  Home-page: https://github.com/Quentendo64/TonieToolbox
6
6
  Author: Quentendo64
@@ -1,19 +1,19 @@
1
- TonieToolbox/__init__.py,sha256=4GrSzQXn-JcheFR01mD-meQl4SSYK9OajTU8wImEFKQ,96
2
- TonieToolbox/__main__.py,sha256=88bs0yCm9Sue7AXIHC37vCDF19fUZGroL_6635P-_Io,7011
3
- TonieToolbox/audio_conversion.py,sha256=Vw6hFbYZYdt1A9zPlRfQNX7sI1iI-bo0xJM7EEnjDP4,7700
1
+ TonieToolbox/__init__.py,sha256=xSV74aYOPiJ2fmGLawFvZ4AXq9TmJg4XV_ttHul3Rcw,96
2
+ TonieToolbox/__main__.py,sha256=qOWIB6JQyEBXyFBEIYbqNtXgFFRrUoHQVnBWiX-pEfw,7114
3
+ TonieToolbox/audio_conversion.py,sha256=10PayO1VQDGee2bcO6JD8zRSFoJRJhO2pBeba5k15vk,7998
4
4
  TonieToolbox/constants.py,sha256=vjSJTX9TDWV9W7rXERd6W0HO5UyiVFYYlCKAf0nwxJM,1991
5
- TonieToolbox/dependency_manager.py,sha256=ZHUhXWnOrRjFq0sI1RKfrg7tMIL3BCsHNmERuZ5ZZqM,14368
5
+ TonieToolbox/dependency_manager.py,sha256=sr7PMBsqQ26bYszM-7Ay-UbKPuBJGyeJV3y1BPAOiBQ,15028
6
6
  TonieToolbox/filename_generator.py,sha256=RqQHyGTKakuWR01yMSnFVMU_HfLw3rqFxKhXNIHdTlg,3441
7
7
  TonieToolbox/logger.py,sha256=Up9fBVkOZwkY61_645bX4tienCpyVSkap-FeTV0v730,1441
8
8
  TonieToolbox/ogg_page.py,sha256=-ViaIRBgh5ayfwmyplL8QmmRr5P36X8W0DdHkSFUYUU,21948
9
9
  TonieToolbox/opus_packet.py,sha256=OcHXEe3I_K4mWPUD55prpG42sZxJsEeAxqSbFxBmb0c,7895
10
10
  TonieToolbox/tonie_analysis.py,sha256=4eOzxHL_g0TJFhuexNHcZXivxZ7eb5xfb9-efUZ02W0,20344
11
- TonieToolbox/tonie_file.py,sha256=dbtNGFNGxu_sfJl2due3Kz5VNJqnUqDC2A6r_WCxxJI,15127
11
+ TonieToolbox/tonie_file.py,sha256=Zy95SJi5xwpOTWC5fyaGv1Xfuq1mKC5U89m7wvNsfEk,15246
12
12
  TonieToolbox/tonie_header.proto,sha256=WaWfwO4VrwGtscK2ujfDRKtpeBpaVPoZhI8iMmR-C0U,202
13
13
  TonieToolbox/tonie_header_pb2.py,sha256=s5bp4ULTEekgq6T61z9fDkRavyPM-3eREs20f_Pxxe8,3665
14
- tonietoolbox-0.1.0.dist-info/licenses/LICENSE.md,sha256=rGoga9ZAgNco9fBapVFpWf6ri7HOBp1KRnt1uIruXMk,35190
15
- tonietoolbox-0.1.0.dist-info/METADATA,sha256=I797RNgbCkKAM2iYK4ty3GP4Mmsl-Pic4AKw3NMCAtQ,8933
16
- tonietoolbox-0.1.0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
17
- tonietoolbox-0.1.0.dist-info/entry_points.txt,sha256=oqpeyBxel7aScg35Xr4gZKnf486S5KW9okqeBwyJxxc,60
18
- tonietoolbox-0.1.0.dist-info/top_level.txt,sha256=Wkkm-2p7I3ENfS7ZbYtYUB2g-xwHrXVlERHfonsOPuE,13
19
- tonietoolbox-0.1.0.dist-info/RECORD,,
14
+ tonietoolbox-0.1.2.dist-info/licenses/LICENSE.md,sha256=rGoga9ZAgNco9fBapVFpWf6ri7HOBp1KRnt1uIruXMk,35190
15
+ tonietoolbox-0.1.2.dist-info/METADATA,sha256=IEvOyo9te58KL5Pxkp9iNTjf3jItjKj6YDbFDh7A0kk,8933
16
+ tonietoolbox-0.1.2.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
17
+ tonietoolbox-0.1.2.dist-info/entry_points.txt,sha256=oqpeyBxel7aScg35Xr4gZKnf486S5KW9okqeBwyJxxc,60
18
+ tonietoolbox-0.1.2.dist-info/top_level.txt,sha256=Wkkm-2p7I3ENfS7ZbYtYUB2g-xwHrXVlERHfonsOPuE,13
19
+ tonietoolbox-0.1.2.dist-info/RECORD,,