Created
February 23, 2017 10:13
-
-
Save NeuroWinter/7c2832a1c63c54b1d71a876ef1074275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
def getArtist(releaseFile): | |
artist = (releaseFile['group']['musicInfo']['artists'][0]['name']).encode('ascii','ignore') | |
return artist | |
def getAlbum(releaseFile): | |
album = (releaseFile['group']['name']).encode('ascii','ignore') | |
return album | |
def getFilePath(releaseFile): | |
path = (releaseFile['torrent']['filePath']).encode('ascii','ignore') | |
return path | |
def searchInLibrary(artist, album, releaseFile): | |
if artist in os.listdir("/home/neuro/UUI/library/"): | |
if album in os.listdir("/home/neuro/UUI/library/"+artist+"/"): | |
print artist + " - " + album + " FOUND" | |
libLocation = ("/home/neuro/UUI/library/"+artist+"/"+album+"/") | |
wmLocation = (dirpath + "/" + getFilePath(releaseFile)) | |
print "COPY FROM: " + libLocation | |
print "COPY TO: " + wmLocation | |
# TODO Move files | |
# shutil.copy(libLocation, wmLocation) | |
def isLossless(releaseFile): | |
if "Lossless" in releaseFile['torrent']['encoding']: | |
return True | |
else: | |
return False | |
for (dirpath, dirnames, filenames) in os.walk("/home/neuro/UUI/"): | |
for file in os.listdir(dirpath): | |
if file.endswith("2.txt"): | |
with open(dirpath + '/' + file) as data_file: | |
try: | |
data = json.load(data_file) | |
if isLossless(data) : | |
searchInLibrary(getArtist(data), getAlbum(data), data) | |
except UnicodeEncodeError: | |
pass | |
except TypeError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment