88import os
99import subprocess
1010
11- from pathlib import Path
1211from services .cache import get_audio_cache
12+ from services .path_utils import expand_path
1313from config import get_config
1414
1515logger = logging .getLogger (__name__ )
@@ -23,7 +23,7 @@ def _get_download_marker(youtube_video_id: str) -> str:
2323
2424def is_download_in_progress (youtube_video_id : str ) -> bool :
2525 """Check if a download is currently in progress for this video."""
26- return Path (_get_download_marker (youtube_video_id )). expanduser (). resolve ( ).exists ()
26+ return expand_path (_get_download_marker (youtube_video_id )).exists ()
2727
2828
2929def start_youtube_download (youtube_video_id : str ):
@@ -41,7 +41,7 @@ def start_youtube_download(youtube_video_id: str):
4141 proc or None if already cached
4242 """
4343 audio_cache = get_audio_cache ()
44- audio_path = Path (config .get_audio_path (youtube_video_id )). expanduser (). resolve ( )
44+ audio_path = expand_path (config .get_audio_path (youtube_video_id ))
4545
4646 if audio_cache .check_file_exists (youtube_video_id ):
4747 logger .info (f"Audio file for video { youtube_video_id } already exists in cache" )
@@ -51,7 +51,7 @@ def start_youtube_download(youtube_video_id: str):
5151 url = f"https://www.youtube.com/watch?v={ youtube_video_id } "
5252
5353 # Create marker file so the /audio endpoint won't serve a partial file
54- marker_path = Path (_get_download_marker (youtube_video_id )). expanduser (). resolve ( )
54+ marker_path = expand_path (_get_download_marker (youtube_video_id ))
5555 try :
5656 marker_path .touch (exist_ok = True )
5757 except Exception as e :
@@ -115,11 +115,9 @@ def finish_youtube_download(youtube_video_id: str, returncode: int):
115115 youtube_video_id: YouTube video ID
116116 returncode: Process exit code (0 = success)
117117 """
118- audio_path = Path (config .get_audio_path (youtube_video_id )).expanduser ().resolve ()
119- marker_path = Path (_get_download_marker (youtube_video_id )).expanduser ().resolve ()
120- stderr_path = (
121- Path (config .get_audio_path (youtube_video_id ) + ".err" ).expanduser ().resolve ()
122- )
118+ audio_path = expand_path (config .get_audio_path (youtube_video_id ))
119+ marker_path = expand_path (_get_download_marker (youtube_video_id ))
120+ stderr_path = expand_path (config .get_audio_path (youtube_video_id ) + ".err" )
123121
124122 # Read stderr for error reporting
125123 error_output = ""
0 commit comments