mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-06 15:16:59 -06:00
update subprocess to Popen with subprocess.PIPE for Python 3.6 stdout piping support (no capture output kwarg)
This commit is contained in:
10
app/sound.py
10
app/sound.py
@@ -32,10 +32,11 @@ class YouTubeHandler:
|
|||||||
config = YouTubeHandler.getConfig(videoid)
|
config = YouTubeHandler.getConfig(videoid)
|
||||||
return config['filename']
|
return config['filename']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
filename = subprocess.run(
|
# Use stdout=PIPE, [Python 3.6] production server support instead of 'capture_output=True' => 'process.stdout'
|
||||||
['youtube-dl', '-x', '--audio-format', 'mp3', '--restrict-filenames', '--get-filename',
|
process = subprocess.Popen(
|
||||||
YouTubeHandler.url(videoid)], encoding='utf-8', capture_output=True).stdout
|
['youtube-dl', '-x', '--audio-format', 'mp3', '--restrict-filenames', '--get-filename', YouTubeHandler.url(videoid)],
|
||||||
filename = filename.split('.')
|
encoding='utf-8', stdout=subprocess.PIPE)
|
||||||
|
filename = process.communicate()[0].split('.')
|
||||||
filename[-1] = 'mp3'
|
filename[-1] = 'mp3'
|
||||||
return '.'.join(filename)
|
return '.'.join(filename)
|
||||||
|
|
||||||
@@ -63,7 +64,6 @@ class YouTubeHandler:
|
|||||||
config = YouTubeHandler.getConfig(videoid)
|
config = YouTubeHandler.getConfig(videoid)
|
||||||
if not os.path.exists(config['path']):
|
if not os.path.exists(config['path']):
|
||||||
subprocess.run(['youtube-dl', '-x', '--restrict-filenames', '--audio-format', 'mp3', YouTubeHandler.url(videoid)])
|
subprocess.run(['youtube-dl', '-x', '--restrict-filenames', '--audio-format', 'mp3', YouTubeHandler.url(videoid)])
|
||||||
print(os.listdir('.'))
|
|
||||||
os.rename(config['filename'], config['path'])
|
os.rename(config['filename'], config['path'])
|
||||||
|
|
||||||
service_functions = {
|
service_functions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user