def set_metatags(album_id, mode): album = get_album(album_id) for p in tag_get_piece_paths(album_id): if mode == 'short': title2tag(p, album['Title']) if mode == 'long': all2tag(p, album['Title'], album['ID']) return ''
def read_albums(album_id): album = get_album(album_id) # get_albums(album['Path'], None, 0) path = os.path.join(AUDIO_ROOT, album['Path']) for d in os.listdir(path): p = u'{}/{}'.format(path, d) if os.path.isdir(p) and d not in SKIP_DIRS: process_album(p, album_id)
def tag_get_piece_paths(album_id): album = get_album(album_id) print(album['Title']) pieces = get_pieces(album_id) paths = [] for piece in pieces: if get_extension(piece['Name']) != 'cue': paths.append(os.path.join(album['Path'], piece['Name'])) return paths
def remove_tag(album_id, tag): album = get_album(album_id) print(album['Title']) pieces = get_pieces(album_id) for piece in pieces: if get_extension(piece['Name']) != 'cue': p = os.path.join(album['Path'], piece['Name']) delete_tag(p, tag) return ''
def albumimageback(album_id, w=None, h=None): album = get_album(album_id) if not album: return HttpResponseNotFound( 'Dit album bestaat niet:"{}"'.format(album_id), ) if not album['Path']: return empty_response() image_path = AUDIO_ROOT + album['Path'] + settings.BACK_FILE return get_image(image_path, w, h)
def remove_piece(album_id, piece_name): album = get_album(album_id) p = os.path.join(album['Path'], piece_name) try: os.remove(p) except FileNotFoundError as ex: ColorPrint.print_c(str(ex), ColorPrint.CYAN) socket_log(str(ex), 'error', album_id) except PermissionError as p: ColorPrint.print_c(str(p), ColorPrint.CYAN) socket_log(str(p), 'error', album_id)
def tag_put_picture(album_id): pic = Picture() album = get_album(album_id) with open(album['Path'] + "/folder.jpg", "rb") as f: pic.data = f.read() if not pic.data: return 'No folder.jpg found' pic.type = id3.PictureType.COVER_FRONT pic.mime = u"image/jpeg" pic.width = 500 pic.height = 500 pic.depth = 16 for p in tag_get_piece_paths(album_id): set_pic(p, pic) return 'success'
def save_album(album_id): album = get_album(album_id) image_path = album['Path'] + COVER_FILE if os.path.exists(image_path): os.remove(image_path) # todo: remove all cached folder files remove_cached_cover(album['Path']) try: clipboard_save_path(album['Path'] + COVER_FILE) except PermissionError as pe: print(str(pe)) print(image_path) return 'not saved' except FileNotFoundError as fe: print(str(fe)) print(image_path) return 'not saved' return 'saved from clipboard:' + image_path
def album_delete(request, album_id): delete_album(album_id) template = loader.get_template('website/album_deleted.html') return HttpResponse( template.render({'album': get_album(album_id)}, request))