first implementation of discid and musicbrainz
This commit is contained in:
parent
4a7912f0ca
commit
53e4b39ebf
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -60,3 +60,6 @@ target/
|
||||||
|
|
||||||
# Vim
|
# Vim
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
*.wav
|
||||||
|
|
54
ripbot.py
54
ripbot.py
|
@ -1,14 +1,52 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import discid
|
||||||
|
import musicbrainzngs as mb
|
||||||
|
|
||||||
process = subprocess.Popen(["cdparanoia", "-B", "--stderr-progress"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
def getTitleAmount():
|
||||||
|
process = subprocess.Popen(["cdparanoia", "-Q", "--stderr-progress", "--"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
startCount = False
|
||||||
|
trackCount = 0
|
||||||
for line in process.stderr:
|
for line in process.stderr:
|
||||||
out = line
|
out = line.decode()
|
||||||
if "outputting to" in out.decode():
|
|
||||||
print(out.decode().strip())
|
if startCount == True and not "TOTAL" in out:
|
||||||
elif "##" == out.decode()[:2]:
|
trackCount += 1
|
||||||
print(out.decode().strip(), end="\r")
|
|
||||||
|
if "===========================================================" in out:
|
||||||
|
startCount = True
|
||||||
|
elif "TOTAL" in out:
|
||||||
|
startCount = False
|
||||||
|
return trackCount
|
||||||
|
|
||||||
|
def getMBbyDisc():
|
||||||
|
disc = discid.read("/dev/cdrom")
|
||||||
|
mb.set_useragent("ripbot", "0.01", "https://git.geekify.de/sqozz/ripbot")
|
||||||
|
releases = mb.get_releases_by_discid(disc.id)
|
||||||
|
if len(releases["disc"]["release-list"]) > 1:
|
||||||
|
print("Found {0} relases by discid {1}".format(releases["disc"]["release-count"], releases["disc"]["id"]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def ripTitles():
|
||||||
|
process = subprocess.Popen(["cdparanoia", "-B", "-l", "--stderr-progress", "--", "\"1-2\""], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
currentTitle = 0
|
||||||
|
for line in process.stderr:
|
||||||
|
out = line.decode()
|
||||||
|
if "outputting to" in out:
|
||||||
|
currentTitle += 1
|
||||||
|
print("Ripping title {0}".format(currentTitle))
|
||||||
|
elif "##" == out[:2]:
|
||||||
|
print(out.strip(), end="\r")
|
||||||
sys.stdout.write("\r")
|
sys.stdout.write("\r")
|
||||||
else:
|
#else:
|
||||||
print(out.decode().strip())
|
#print(out.strip())
|
||||||
|
|
||||||
|
titleAmount = getTitleAmount()
|
||||||
|
print("Found {0} titles".format(titleAmount))
|
||||||
|
getMBbyDisc()
|
||||||
|
print("Start ripping")
|
||||||
|
#ripTitles()
|
||||||
|
|
||||||
|
# vim:ts=2 sts=2 sw=2 noexpandtab:
|
||||||
|
|
Loading…
Reference in a new issue