mimbres commited on
Commit
d922292
1 Parent(s): 2c21e09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -76,35 +76,35 @@ def prepare_media(source_path_or_url: os.PathLike,
76
  # os.remove(mp4_file)
77
  # except Exception as e:
78
  # try:
79
- try:
80
- with open(log_file, 'w') as lf:
81
- # Try alternative
82
- print(f"Failed with PyTube, error: {e}. Trying yt-dlp...")
83
- audio_file = './downloaded/yt_audio'
84
- # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
85
- # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
86
- # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
87
- # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
88
- # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
89
- # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
90
- command = ['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
91
- '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
92
- '--force-overwrites', '--username', 'oauth2', '--password', '', '-v']
93
- if simulate:
94
- command = command + ['-s']
95
- process = subprocess.Popen(command,
96
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
97
-
98
- for line in iter(process.stdout.readline, ''):
99
- lf.write(line)
100
- lf.flush()
101
- process.stdout.close()
102
- process.wait()
103
-
104
- audio_file += '.mp3'
105
- except Exception as e:
106
- print(f"Alternative downloader failed, error: {e}. Please try again later!")
107
- return None
108
  else:
109
  raise ValueError(source_type)
110
 
 
76
  # os.remove(mp4_file)
77
  # except Exception as e:
78
  # try:
79
+ # try:
80
+ with open(log_file, 'w') as lf:
81
+ # Try alternative
82
+ print(f"Failed with PyTube, error: {e}. Trying yt-dlp...")
83
+ audio_file = './downloaded/yt_audio'
84
+ # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
85
+ # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
86
+ # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
87
+ # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
88
+ # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
89
+ # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
90
+ command = ['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
91
+ '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
92
+ '--force-overwrites', '--username', 'oauth2', '--password', '', '-v']
93
+ if simulate:
94
+ command = command + ['-s']
95
+ process = subprocess.Popen(command,
96
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
97
+
98
+ for line in iter(process.stdout.readline, ''):
99
+ lf.write(line)
100
+ lf.flush()
101
+ process.stdout.close()
102
+ process.wait()
103
+
104
+ audio_file += '.mp3'
105
+ # except Exception as e:
106
+ # print(f"Alternative downloader failed, error: {e}. Please try again later!")
107
+ # return None
108
  else:
109
  raise ValueError(source_type)
110