forked from crisbal/album-splitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
split_init.py
47 lines (38 loc) · 1.12 KB
/
split_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import sys
import pkgutil
# ============================
# General setup
# ============================
import MetaDataProviders
METADATA_PROVIDERS = [n for _, n, _ in pkgutil.iter_modules(['MetaDataProviders'])]
# =============================
# Youtube_dl configuration
# =============================
class YdlLogger(object):
def debug(self, msg):
pass
def warning(self, msg):
pass
def error(self, msg):
print(msg)
def ydl_hook(d):
if d['status'] == 'downloading':
sys.stdout.write('\r\033[K')
sys.stdout.write('\tDownloading video | ETA: {} seconds'.format(str(d["eta"])))
sys.stdout.flush()
elif d['status'] == 'finished':
sys.stdout.write('\r\033[K')
sys.stdout.write('\tDownload complete\n\tConverting video to music file...')
sys.stdout.flush()
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': '%(id)s.%(ext)s',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'wav',
'preferredquality': '0',
}],
'logger': YdlLogger(),
'progress_hooks': [ydl_hook],
}