Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into master
  • Loading branch information
Kayzels committed Oct 13, 2020
2 parents 7af5480 + aa89754 commit 414532d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
Empty file added music_modify/__init__.py
Empty file.
40 changes: 17 additions & 23 deletions music_modify/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,16 @@ def remove_duplicates(song: Song, tag: SongTag):
values = tag.get_tag(song.id3)
if values is None:
return
else:
values = tuple([tuple(value) # type: ignore
if isinstance(value, list)
else value
for value in values])
new_list = [list(value)
if isinstance(value, tuple)
else value
for value in list(OrderedDict.fromkeys((values)))]
tag.set_tag(song.id3, new_list)
song.save()
values = tuple(tuple(value) # type: ignore
if isinstance(value, list)
else value
for value in values)
new_list = [list(value)
if isinstance(value, tuple)
else value
for value in list(OrderedDict.fromkeys((values)))]
tag.set_tag(song.id3, new_list)
song.save()


def _split_value(value: str) -> List[str]:
Expand Down Expand Up @@ -271,10 +270,8 @@ def _replace_value(values_copy: np.ndarray,
np.append(values_copy, [new_value], 0)
elif tag_length == 2:
pair = cast(List[str], pair)
if item_index == 0:
new_pair = [new_value, pair[1]]
else:
new_pair = [pair[0], new_value]
new_pair = [new_value, pair[1]] if item_index == 0\
else [pair[0], new_value]
np.append(values_copy, [new_pair], 0)


Expand Down Expand Up @@ -345,12 +342,10 @@ def copy_values(song: Song,
Song data should be sent to. If None, uses the original song.
By default None
"""
if copy_mode & CopyType.Across:
if to_song is None:
if to_song is None:
if copy_mode & CopyType.Across:
return
else:
if to_song is None:
to_song = song
to_song = song
to_song = cast(Song, to_song)
tag = tag_selection.tag
copy_tag = tag_selection.copy_tag
Expand Down Expand Up @@ -450,7 +445,6 @@ def add_discogs_tags(response: requests.Response,
# tag_workbook = openpyxl.load_workbook(
# Path.cwd()/Path('excel', 'excel_current_info.xlsx'))


def _add_values_to_sheet(tag: SongTag,
song: Song,
sheet: Worksheet,
Expand Down Expand Up @@ -522,14 +516,14 @@ def add_values_to_excel(song: Song):
role_sheet,
people_sheet)

genre_sheet = tag_workbook['Genres']
genre = songtag_functions.map_tag('Genre')
if genre is not None:
genre_sheet = tag_workbook['Genres']
_add_values_to_sheet(genre, song, genre_sheet)

publisher_sheet = tag_workbook['Publishers']
publisher = songtag_functions.map_tag('Publisher')
if publisher is not None:
publisher_sheet = tag_workbook['Publishers']
_add_values_to_sheet(publisher, song, publisher_sheet)

# ! to reduce excess memory, spreadsheet is not saved in this function.
Expand Down
4 changes: 2 additions & 2 deletions music_modify/actions/download_lastfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def get_last_fm_data(payload: Dict[str, str]) -> requests.Response:
payload['api_key'] = API_KEY
payload['format'] = 'json'

response = requests.get(url, headers=headers, params=payload)
return response
return requests.get(url, headers=headers, params=payload)
# endregion


Expand All @@ -57,6 +56,7 @@ def get_lastfm_mappings() -> pd.core.frame.DataFrame:
pd.core.frame.DataFrame
Dataframe of mappings for Last.fm tags
"""

relative_path = str(Path("music_modify", "excel", "download_lastfm_mappings.xlsx"))
excel_file = file_utils.get_resource_path(relative_path)
# excel_file = Path.cwd()/Path("excel", "download_lastfm_mappings.xlsx")
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def read(fname: str):
keywords="mp3 music tags",
url="https://github.com/KyzanHartwig/Music-Modify",
long_description=read('README.md'),
packages=find_packages(exclude=["config"]),
package_dir={"": "music_modify"},
packages=find_packages(where="music_modify", exclude=["config"]),
python_requires='>=3.8',
)

0 comments on commit 414532d

Please sign in to comment.