question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

itunespy can't set attribute

See original GitHub issue
def get_from_itunes(SONG_NAME):
    """Try to download the metadata using itunespy."""
    # Try to get the song data from itunes
    try:
        SONG_INFO = itunespy.search_track(SONG_NAME)
        # Before returning convert all the track_time values to minutes.
        for song in SONG_INFO:
            song.track_time = round(song.track_time / 60000, 2)
        return SONG_INFO
    except Exception:
        pass

The code above tries to set the track_time, but that setter isn’t defined in the itunespy library, so it doesn’t work and doesn’t even throw an error. This is related to #77 as it only get songs from gaana. The solution would be to remove setting track_time, since something else is already implemented in the source library.

I made a pull request for this, also adding a print for exceptions instead of just pass.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
danimateocommented, Jul 11, 2020

Yes, my bad. I’ll use the logger.

1reaction
danimateocommented, Jul 10, 2020

So, here is the previous commit to the ResultItem class in itunespy and here is the newest one. The old one uses normal python attributes and the new one uses @property decorators, which are read only unless a setter is defined.

class ResultItem(object):
    @property
    def track_time(self):
        return "test"

test_result = ResultItem()
test_result.track_time = "test_new"

The abovde code throws:

Traceback (most recent call last):
  File "testpy.py", line 8, in <module>
    test_result.track_time = "test"
AttributeError: can't set attribute

Could you please check again? Anyway, cool script 😃 I was looking for something like this for some time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

setAttributes(_:ofItemAtPath:) | Apple Developer Documentation
A dictionary containing as keys the attributes to set for path and as values the corresponding value for the attribute. You can set...
Read more >
AttributeError: can't set attribute in python - Stack Overflow
As I tried to overwrite it in my code, it caused AttributeError: can't set attribute . Just simply renaming my variable from self.hparams...
Read more >
iTunes: Can't Change Song Name, Artist, or Album on Get Info ...
iTunes: Can't Change Song Name, Artist, or Album on Get Info Screen ... Select “OK“. Wait until the attributes are applied to your...
Read more >
Python error saying "AttributeError: can't set attribute" - Intellipaat
I'm trying to execute the following python code: class C(object): def __init__(self): ... > c.x = 10 AttributeError: can't set attribute.
Read more >
A Complete Guide to Data Attributes | CSS-Tricks
Syntax. It can be awfully handy to be able to make up your own HTML attributes and put your own information inside them....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found