libsaria: Manually set artwork through a copy_in_file() function

I created this function in the cache to make a generic way to copy
outside files into the cache tree.  It makes sense to do this in the
cache, since I want to keep everything self-contained.
This commit is contained in:
Bryan Schumaker 2011-05-07 16:49:41 -04:00
parent 2a78d870ee
commit bafdc6ef20
2 changed files with 6 additions and 6 deletions

View File

@ -77,7 +77,4 @@ def get_artwork(file):
threads.background(get_album_art, file)
def set_artwork(artist, album, img_path):
file = cache.open_file(artist, album, "Folder.jpg")
new_img = open(img_path)
file.write(new_img.read())
file.close()
cache.copy_in_file(artist, album, "Folder.jpg", img_path)

View File

@ -37,6 +37,9 @@ def get_item(artist, album, title, file, cache_func):
cache_path = fill_cache(artist, album, title, cache_func, cache_path)
return cache_path
def open_file(artist, album, file):
def copy_in_file(artist, album, file, orig_file):
cache_path = make_cache_path(artist, album, file)
return open(cache_path, 'w')
orig = open(orig_file)
f = open(cache_path, 'w')
f.write(orig.read())
f.close()