Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: list indices must be integers or slices, not str #35

Closed
igorgukasyan opened this issue May 12, 2024 · 4 comments
Closed

TypeError: list indices must be integers or slices, not str #35

igorgukasyan opened this issue May 12, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@igorgukasyan
Copy link

Hello,

While running a loop with syncedlyrics.search(), I sometimes face the following issue:

lrc = syncedlyrics.search("Synthetic Dream lextrical", allow_plain_format=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/lib/python3.11/site-packages/syncedlyrics/__init__.py", line 59, in search
_l = provider.get_lrc(search_term)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/anaconda3/lib/python3.11/site-packages/syncedlyrics/providers/musixmatch.py", line 120, in get_lrc
tracks = body["track_list"]
~~~~^^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str

my code:

for index, row in combined_data.iterrows():
    song = row['combined'] 
    lyrics = syncedlyrics.search(song, allow_plain_format=True)  
    data.at[index, 'lyrics'] = lyrics

What partially helped me was time.sleep(180) after each error and retrying the same values before skipping, yet it does not always work.

@moehmeni
Copy link
Owner

Hi,
Apparently It is because of captcha request from MusixMatch,. You can clone the repo for latest changes that I just made so you can test again and please let me know if the problem persisted.

@moehmeni moehmeni added the bug Something isn't working label May 18, 2024
@jagauthier
Copy link

Can you implement it so that the return code for not finding lyrics is different than the return code for this error?
It makes the wrapper for this function not know the difference. If there isn't a lyric, I want to move on. If there is an API issue, I want to wait and retry.

@moehmeni
Copy link
Owner

moehmeni commented May 19, 2024

@jagauthier You can somehow grab all the info with the logs (-v or setting level to debug), but in case of API error, it checks the next providers so you would not get a limit most likely. Why would you wait for API limits when there are other providers?

@jagauthier
Copy link

jagauthier commented May 19, 2024

Maybe I am using it wrong, but in my code:

    print(f"Seeking: '{artist}', '{title}', {fullpath}")
    try:
        lrc = syncedlyrics.search(f"{artist} {title}", allow_plain_format=True, save_path=lrc_file_name, providers=providers)
    except TypeError:
        type_error = True
    except:
        lrc = None
        other_exception = True

where
providers = ["NetEase", "LrcLib", "Musixmatch", ]

It only ever uses MusixMatch. I've never got a lyric hit from one of the other providers.
If I change the providers and remove MusixMatch then use a extremely popular artist and album (Taylor Swift and Midnights)

providers = ["NetEase", "LrcLib" ]

I get no lyrical hits.

0%, 0: /data/containers/plex/data/Music/Taylor Swift/Midnights (2022)/Taylor Swift - Midnights - 01 - Lavender Haze.mp3
Seeking: 'Taylor Swift', 'Lavender Haze', /data/containers/plex/data/Music/Taylor Swift/Midnights (2022)/Taylor Swift - Midnights - 01 - Lavender Haze.mp3
**Lyrics not found.**
5%, 0: /data/containers/plex/data/Music/Taylor Swift/Midnights (2022)/Taylor Swift - Midnights - 02 - Maroon.mp3
Seeking: 'Taylor Swift', 'Maroon', /data/containers/plex/data/Music/Taylor Swift/Midnights (2022)/Taylor Swift - Midnights - 02 - Maroon.mp3
**Lyrics not found.**
10%, 0: /data/containers/plex/data/Music/Taylor Swift/Midnights (2022)/Taylor Swift - Midnights - 03 - Anti‐Hero.mp3
Seeking: 'Taylor Swift', 'Anti-Hero', /data/containers/plex/data/Music/Taylor Swift/Midnights (2022)/Taylor Swift - Midnights - 03 - Anti‐Hero.mp3
**Lyrics not found.**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants