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

Show proper metadata including album and artist whenever possible #739

Merged
merged 3 commits into from Dec 14, 2017

Conversation

vn-ki
Copy link
Member

@vn-ki vn-ki commented Dec 13, 2017

Now fixes metadata when playing songs. This could be extended to fixing metadata (track title, album, artist, album art) when downloading songs. But that would add mutagen as a dependency; so I was not sure of implementing that (That could be a future PR). Switches to old method of displaying thumbnails if no proper metadata was found. Please see attached image. Fixes #209 and #495 .

image

@ids1024
Copy link
Contributor

ids1024 commented Dec 13, 2017

This could be extended to fixing metadata (track title, album, artist, album art) when downloading songs. But that would add mutagen as a dependency

Currently mps_youtube/commands/download.py has a very primitive parser (extract_metadata) to try to get artist and title from songs, and uses avconv/ffmpeg to add the metadata.

But of course, this solution with lastfm is better, and sharing the metadata through mpris is great too.

Copy link
Member

@hrnr hrnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I really like this change. Exporting metadata via MPRIS is great.

I have commented some minor issues.

@@ -301,7 +301,9 @@ def setproperty(self, name, val):
'/CurrentPlaylist/ytid/' + trackid, variant_level=1),
'mpris:length' : dbus.Int64(length * 10**6, variant_level=1),
'mpris:artUrl' : dbus.String(arturl, variant_level=1),
'xesam:title' : dbus.String(title, variant_level=1) }
'xesam:title' : dbus.String(title, variant_level=1),
'xesam:artist' : dbus.Array(artist),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please specify also here signature and variant level explicitly. See how it is done on line 162.

@@ -374,14 +375,24 @@ def _get_input_file():
def _launch_player(song, songdata, cmd):
""" Launch player application. """

#song.title
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some debug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya! Sorry.

else :
arturl = metadata['album_art_url']
temp = (song.ytid, metadata['track_title'], song.length, arturl, [metadata['artist']], metadata['album'])
metadata = temp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can assign to metadata directly, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why I did that. XD

@hrnr
Copy link
Member

hrnr commented Dec 13, 2017

Thanks again for this. Seems to work reasonably well for most of the songs. Is usage of last.fm API anyhow limited? I'm just worried if all of our users start to use this, we might get blocked.

For this reason, there should be a way to change the API key. It can be similar to what we have for youtube API key.

@vn-ki
Copy link
Member Author

vn-ki commented Dec 13, 2017

@hrnr I don't think the last.fm API would be problem. Their terms of service says the limit is 5 requests per ip per sec (averaged over 5 minutes). That is not happening. But we will have to give them proper credits for their data. I was thinking about implementing this for downloads too. Is dependency on mutagen a problem?

@hrnr
Copy link
Member

hrnr commented Dec 13, 2017

Thanks. I have tested the MPRIS side and all looks good now (all datatypes correct etc.).

@ids1024
Copy link
Contributor

ids1024 commented Dec 13, 2017

Is dependency on mutagen a problem?

I'm hesitant to add non-optional dependencies, but mutagen seems to be commonly packaged by distributions (Arch and Debian, at least), so it should be fine.

@ids1024 ids1024 merged commit 8a55803 into mps-youtube:develop Dec 14, 2017
@tommysolsen
Copy link
Member

We could also implement the musicbrainz project as a source for music information instead of last.fm.
Musicbrainz is an open source project and the data is released under CC0, without any need to mention the musicbrainz project when using the data.

It also does not require an API key so the functionality won't break if the hardcoded key is revoked in the future. We're also not attributing them when using their data(we also need to show a link to https://last.fm).

@vn-ki
Copy link
Member Author

vn-ki commented Dec 14, 2017

@Razesdark Do they provide the album art with the json response? Their web service don't expose many things. Is there a way to search using both title and artist? I tried a few songs and the top result don't match (Which means more work to find the correct result). If there is way to search both title and artist this would improve. But still I couldn't see the ablum art in the json response. I have seen many open source projects using last.fm (Jockey and Phonograph, to name some).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

artist, album, song title metadata
4 participants