ytmdl: itunespy can't set attribute

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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (14 by maintainers)

Most upvoted comments

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

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.