Skip to content

Commit a9251c8

Browse files
committed
Merge branch 'unstable'
2 parents 68e54cb + 9c28a19 commit a9251c8

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'youtube-search-python',
2626
'pyDes',
2727
'urllib3',
28-
'simber==0.2.5',
28+
'simber==0.2.6',
2929
'rich',
3030
'musicbrainzngs',
3131
'ytmusicapi',

ytmdl/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Store the version of the package
2-
__version__ = "2022.12.25"
2+
__version__ = "2023.02.28"

ytmdl/core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def meta(conv_name: str, song_name: str, search_by: str, args):
230230
else:
231231
# Else add metadata in ordinary way
232232
logger.info('Getting song data for {}...'.format(search_by))
233-
TRACK_INFO = metadata.SEARCH_SONG(search_by, filters=[
233+
TRACK_INFO = metadata.SEARCH_SONG(search_by, song_name, filters=[
234234
args.artist, args.album],
235235
disable_sort=args.disable_sort)
236236

@@ -255,5 +255,11 @@ def meta(conv_name: str, song_name: str, search_by: str, args):
255255
logger.warning(
256256
"Metadata was skipped because -1 was entered as the option")
257257
return None
258+
# If amending the search, get the new search and retry
259+
elif option == -2:
260+
logger.info(
261+
"Amending the search because -2 was entered as the option")
262+
search_by = utility.get_new_meta_search_by(search_by)
263+
return meta(conv_name, song_name, search_by, args)
258264

259265
return TRACK_INFO[option]

ytmdl/metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _extend_to_be_sorted_and_rest(provider_data, to_be_sorted, rest, filters):
207207
rest.extend(provider_data[10:])
208208

209209

210-
def SEARCH_SONG(q="Tera Buzz", filters=[], disable_sort=False):
210+
def SEARCH_SONG(search_by="Tera Buzz", song_name="Tera Buzz", filters=[], disable_sort=False):
211211
"""Do the task by calling other functions."""
212212
to_be_sorted = []
213213
rest = []
@@ -230,7 +230,7 @@ def SEARCH_SONG(q="Tera Buzz", filters=[], disable_sort=False):
230230
if provider in GET_METADATA_ACTIONS:
231231
logger.debug(f"Searching metadata with {provider}")
232232
data_provider = GET_METADATA_ACTIONS.get(
233-
provider, lambda _: None)(q)
233+
provider, lambda _: None)(search_by)
234234
if data_provider:
235235
_extend_to_be_sorted_and_rest(
236236
data_provider, to_be_sorted, rest, filters)
@@ -256,7 +256,7 @@ def SEARCH_SONG(q="Tera Buzz", filters=[], disable_sort=False):
256256
return to_be_sorted
257257

258258
# Send the data to get sorted
259-
sorted_data = _search_tokens(q, to_be_sorted)
259+
sorted_data = _search_tokens(song_name, to_be_sorted)
260260

261261
# Add the unsorted data
262262
sorted_data += rest
@@ -265,7 +265,7 @@ def SEARCH_SONG(q="Tera Buzz", filters=[], disable_sort=False):
265265

266266

267267
if __name__ == '__main__':
268-
n = SEARCH_SONG("Cradles", ["Sub Urban", None])
268+
n = SEARCH_SONG("Cradles", "Cradles", ["Sub Urban", None])
269269

270270
for i in n:
271271
print(i.track_name + ' by ' + i.artist_name + ' of ' + i.collection_name)

ytmdl/song.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def getChoice(SONG_INFO, type):
147147

148148
logger.info('Choose One {}'.format(
149149
'(One with [M] is verified music)'
150-
if type == 'mp3' else '(Enter -1 to skip metadata)'))
150+
if type == 'mp3' else '(Enter -1 to skip metadata or -2 to amend search)'))
151151

152152
results = len(SONG_INFO)
153153

@@ -172,8 +172,9 @@ def getChoice(SONG_INFO, type):
172172
# If the choice is 0 then try to print more results
173173
# The choice is valid if it is in the range and it is greater than 0
174174
# We also need to break when the user enters -1 which means the exec
175-
# will skip the current song
176-
if choice == -1 or (choice <= len(SONG_INFO) and choice > 0):
175+
# will skip the current song or -2 which means the exec will amend the
176+
# search and retry
177+
if choice == -1 or choice == -2 or (choice <= len(SONG_INFO) and choice > 0):
177178
break
178179
elif choice == 0 and results < len(SONG_INFO):
179180
PRINT_WHOLE = True
@@ -182,7 +183,7 @@ def getChoice(SONG_INFO, type):
182183
else:
183184
PRINT_WHOLE = False
184185

185-
return choice - 1 if choice != -1 else -1
186+
return choice - 1 if (choice != -1 and choice != -2) else choice
186187

187188

188189
def set_MP3_data(song, song_path):
@@ -389,8 +390,8 @@ def setData(SONG_INFO, is_quiet, song_path, datatype='mp3', choice=None):
389390
option = _get_option(SONG_INFO, is_quiet, choice)
390391
logger.debug(option)
391392

392-
# If -1 then skip setting the metadata
393-
if option == -1:
393+
# If -1 or -2 then skip setting the metadata
394+
if option == -1 or option == -2:
394395
return option
395396

396397
song = SONG_INFO[option]

0 commit comments

Comments
 (0)