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:
parent
2a78d870ee
commit
bafdc6ef20
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue