mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Implement basic threading
This commit is contained in:
25
spotdl.py
25
spotdl.py
@@ -13,6 +13,7 @@ import urllib.request
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
def generate_songname(tags):
|
def generate_songname(tags):
|
||||||
@@ -374,19 +375,25 @@ def grab_single(raw_song, number=None):
|
|||||||
if not check_exists(file_name, raw_song, islist=islist):
|
if not check_exists(file_name, raw_song, islist=islist):
|
||||||
if download_song(file_name, content):
|
if download_song(file_name, content):
|
||||||
print('')
|
print('')
|
||||||
input_song = file_name + args.input_ext
|
t = threading.Thread(target=finalize, args=(file_name, meta_tags))
|
||||||
output_song = file_name + args.output_ext
|
#finalize(file_name, meta_tags)
|
||||||
convert.song(input_song, output_song, args.folder,
|
t.start()
|
||||||
avconv=args.avconv, verbose=args.verbose)
|
|
||||||
if not args.input_ext == args.output_ext:
|
|
||||||
os.remove(os.path.join(args.folder, input_song))
|
|
||||||
|
|
||||||
if not args.no_metadata:
|
|
||||||
metadata.embed(os.path.join(args.folder, output_song), meta_tags)
|
|
||||||
else:
|
else:
|
||||||
print('No audio streams available')
|
print('No audio streams available')
|
||||||
|
|
||||||
|
|
||||||
|
def finalize(file_name, meta_tags):
|
||||||
|
input_song = file_name + args.input_ext
|
||||||
|
output_song = file_name + args.output_ext
|
||||||
|
convert.song(input_song, output_song, args.folder,
|
||||||
|
avconv=args.avconv, verbose=args.verbose)
|
||||||
|
if not args.input_ext == args.output_ext:
|
||||||
|
os.remove(os.path.join(args.folder, input_song))
|
||||||
|
|
||||||
|
if not args.no_metadata:
|
||||||
|
metadata.embed(os.path.join(args.folder, output_song), meta_tags)
|
||||||
|
|
||||||
|
|
||||||
class TestArgs(object):
|
class TestArgs(object):
|
||||||
manual = False
|
manual = False
|
||||||
input_ext = '.m4a'
|
input_ext = '.m4a'
|
||||||
|
|||||||
Reference in New Issue
Block a user