Skip to content

Instantly share code, notes, and snippets.

@avidal
Created November 8, 2012 13:59
Show Gist options
  • Save avidal/4038962 to your computer and use it in GitHub Desktop.
Save avidal/4038962 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
j = lambda *p: os.path.join(*p)
# Permanent directory paths are $goodroot/$album
GOOD_ROOT = u"/media/raid/music"
# Download directory paths are $origroot/$tracker/$album
ORIG_ROOT= u"/media/raid/oink"
class Album(object):
album = u""
tracker = u""
orig_path = u""
good_path = u""
def __init__(self, album, tracker):
self.album = album.decode('utf-8')
self.tracker = tracker.decode('utf-8')
self.orig_path = j(ORIG_ROOT, tracker, album)
good_path = j(GOOD_ROOT, album)
if os.path.isdir(good_path):
self.good_path = good_path
def __unicode__(self):
return u"{0} ({1})".format(self.album, self.tracker)
def __str__(self):
return unicode(self).encode('utf-8')
def find_albums():
albums = []
for tracker in os.listdir(ORIG_ROOT):
r = j(ORIG_ROOT, tracker)
if os.path.isdir(r) and tracker != "torrents":
for album in os.listdir(r):
albums.append(Album(album, tracker))
return albums
def main():
albums = find_albums()
# Print out all albums that have a good path
for album in albums:
if album.good_path:
print album
if __name__ == "__main__":
import sys
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment