mimbres commited on
Commit
6ee3139
1 Parent(s): 2c11bc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -12
app.py CHANGED
@@ -68,19 +68,8 @@ def prepare_media(source_path_or_url: os.PathLike,
68
  audio_file = source_path_or_url
69
  elif source_type == 'youtube_url':
70
  # # Download from youtube
71
- # try:
72
- # # Try PyTube first
73
- # yt = YouTube(source_path_or_url)
74
- # audio_stream = min(yt.streams.filter(only_audio=True), key=lambda s: s.bitrate)
75
- # mp4_file = audio_stream.download(output_path='downloaded') # ./downloaded
76
- # audio_file = mp4_file[:-3] + 'mp3'
77
- # subprocess.run(['ffmpeg', '-i', mp4_file, '-ac', '1', audio_file])
78
- # os.remove(mp4_file)
79
  with open(log_file, 'w') as lf:
80
  audio_file = './downloaded/yt_audio'
81
- # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
82
- # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
83
- # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
84
  command = ['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
85
  '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
86
  '--force-overwrites', '--username', 'oauth2', '--password', '', '-v']
@@ -94,7 +83,7 @@ def prepare_media(source_path_or_url: os.PathLike,
94
  if "www.google.com/device" in line:
95
  hl_text = line.replace("https://www.google.com/device", "\033[93mhttps://www.google.com/device\x1b[0m").split()
96
  hl_text[-1] = "\x1b[31;1m" + hl_text[-1] + "\x1b[0m"
97
- lf.write(' '.join(hl_text)); lf.flush()
98
  process.stdout.close()
99
  process.wait()
100
 
 
68
  audio_file = source_path_or_url
69
  elif source_type == 'youtube_url':
70
  # # Download from youtube
 
 
 
 
 
 
 
 
71
  with open(log_file, 'w') as lf:
72
  audio_file = './downloaded/yt_audio'
 
 
 
73
  command = ['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
74
  '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
75
  '--force-overwrites', '--username', 'oauth2', '--password', '', '-v']
 
83
  if "www.google.com/device" in line:
84
  hl_text = line.replace("https://www.google.com/device", "\033[93mhttps://www.google.com/device\x1b[0m").split()
85
  hl_text[-1] = "\x1b[31;1m" + hl_text[-1] + "\x1b[0m"
86
+ lf.write(' '.join(hl_text[])); lf.flush()
87
  process.stdout.close()
88
  process.wait()
89