kabigon 0.8.9__py3-none-any.whl → 0.8.10__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.
kabigon/ytdlp.py CHANGED
@@ -1,6 +1,5 @@
1
- import hashlib
2
1
  import os
3
- import tempfile
2
+ import uuid
4
3
  from pathlib import Path
5
4
 
6
5
  import yt_dlp
@@ -26,9 +25,10 @@ def download_audio(url: str, outtmpl: str | None = None) -> None:
26
25
  ydl_opts["outtmpl"] = outtmpl
27
26
 
28
27
  ffmpeg_path = os.getenv("FFMPEG_PATH")
29
- if ffmpeg_path is None:
28
+ if ffmpeg_path is not None:
30
29
  ydl_opts["ffmpeg_location"] = ffmpeg_path
31
30
 
31
+ logger.info("Downloading audio from URL: {} with options: {}", url, ydl_opts)
32
32
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
33
33
  ydl.download([url])
34
34
 
@@ -46,16 +46,16 @@ class YtdlpLoader(Loader):
46
46
  self.load_audio = whisper.load_audio
47
47
 
48
48
  def load(self, url: str) -> str:
49
- temp_dir = Path(tempfile.gettempdir())
50
- outtmpl = hashlib.sha512(url.encode("utf-8")).hexdigest()
51
- path = (temp_dir / outtmpl).with_suffix(".mp3")
52
-
49
+ outtmpl = uuid.uuid4().hex[:20]
50
+ path = str(Path(outtmpl).with_suffix(".mp3"))
53
51
  download_audio(url, outtmpl=outtmpl)
54
- audio = self.load_audio(path)
55
52
 
56
- # Clean up the audio file
57
- os.remove(path)
53
+ try:
54
+ audio = self.load_audio(path)
55
+ logger.info("Transcribing audio file: {}", path)
56
+ result = self.model.transcribe(audio)
57
+ finally:
58
+ # Clean up the audio file
59
+ os.remove(path)
58
60
 
59
- logger.info("Transcribing audio file: {}", path)
60
- result = self.model.transcribe(audio)
61
61
  return result.get("text", "")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kabigon
3
- Version: 0.8.9
3
+ Version: 0.8.10
4
4
  Author-email: narumi <toucans-cutouts0f@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.10
@@ -13,9 +13,9 @@ kabigon/twitter.py,sha256=aRqAiFxIwln6lteWdoF6SmvbzO62yBTQRzcB7UcVJwk,1046
13
13
  kabigon/utils.py,sha256=eNTLtHLSB2erDac2HH3jWemgfr8Ou_ozwVb8h9BD-4g,922
14
14
  kabigon/youtube.py,sha256=F9GpLa0iUy03wYU94RrrnrXa6ExqbG6CZpqx5bPENWE,1106
15
15
  kabigon/youtube_ytdlp.py,sha256=Y6h55wYF-5PdxLRxsznFtJDypCedD8g-hY9fgCnfvbg,722
16
- kabigon/ytdlp.py,sha256=ex_at_1irwHgcl20Mm0mRZp-rTM92OHnVC5dWQCkI1c,1677
17
- kabigon-0.8.9.dist-info/METADATA,sha256=T8EHDM6dcghksnn6mOQ1548AvmYBfYlCefo4eIF9DBo,1264
18
- kabigon-0.8.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
- kabigon-0.8.9.dist-info/entry_points.txt,sha256=O3FYAO9w-NQvlGMJrBvtrnGHSK2QkUnQBTa30YXRbVE,45
20
- kabigon-0.8.9.dist-info/licenses/LICENSE,sha256=H2T3_RTgmcngMeC7p_SXT3GwBLkd2DaNgAZuxulcfiA,1066
21
- kabigon-0.8.9.dist-info/RECORD,,
16
+ kabigon/ytdlp.py,sha256=4AjPY0W8IxbEhCNVXpi_KbBQLGrWn5ThrchhffcJIIU,1718
17
+ kabigon-0.8.10.dist-info/METADATA,sha256=XGIIEjC0MWovjzhfXrnXsBE3XxGN2V82Y9Y3eiQTjpQ,1265
18
+ kabigon-0.8.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
+ kabigon-0.8.10.dist-info/entry_points.txt,sha256=O3FYAO9w-NQvlGMJrBvtrnGHSK2QkUnQBTa30YXRbVE,45
20
+ kabigon-0.8.10.dist-info/licenses/LICENSE,sha256=H2T3_RTgmcngMeC7p_SXT3GwBLkd2DaNgAZuxulcfiA,1066
21
+ kabigon-0.8.10.dist-info/RECORD,,