yask123 / Instant-Music-Downloader

🎷 Downloads Music From The Web
http://iyask.me/Instant-Music-Downloader/
1.41k stars 161 forks source link

feature: Metadata #38

Open Otoris opened 8 years ago

Otoris commented 8 years ago

What if this could grab the relevant file metadata + file title and apply it after it's been downloaded from YouTube automagically? Would definitely help keep an iTunes library clean.

picklepicklepick commented 8 years ago

Don't YT files have ID3 tags in them anyway?

yask123 commented 8 years ago

It is possible to implement this. I recently wrote which grabs just album art for all your downloaded songs, you can try it : http://iyask.me/fixalbumart/ I'll work on it if I get some time in weekend.

gamegoofs2 commented 8 years ago

I tried implementing youtube-dl's "--metadata-from-title" and "--add-metadata" but things weren't turning out well. I tried downloading Only Love by Mumford and Sons and it thought the title was "Only Love - Mumford and" and the artist was "Sons".

I'd be willing to add this feature if anyone has any ideas of pulling the metadata from the youtube download.

yask123 commented 8 years ago

Added this feature in commit https://github.com/yask123/Instant-Music-Downloader/commit/71145bc3e0cf2eba5e7b2aa3082cd38d13ae66ad Update sudo pip install instantmusic --upgrade to try.

yask123 commented 8 years ago

Not closing this issue since Its not 100% complete. Currently it assumes the song tittle in youtube is written as Artist name - Song name which is true in most of the cases.

ewtdsar

Thus it currently doesn't write album name.

I plan to fix this in future. See: https://github.com/yask123/Instant-Music-Downloader/blob/master/README.md#mp3-tags

Otoris commented 8 years ago

Something like gracenote or ACRCloud could be used to grab metadata. Only issue is it requires uploading at least a part of the song after it is downloaded by youtube-dl.

ssundarraj commented 8 years ago

Musicbrainz requires you to fingerprint and send the song. This could be used instead of uploading the entire song.

yask123 commented 8 years ago

Yep , Musicbrainz cromaprint is awesome, trying it.

[Update] Unfortunately , for the given file : it couldn't return any result:

URL with fingerprint: `http://api.acoustid.org/v2/lookup?client=ULjKruIg&meta=recordings+releasegroups+compress&duration=641&fingerprint=AQADtMpCLmawcsUTHX_wH8meBGFC6rjwaAueOcaPUnqM5pIRR01yqA_OHK5I6IuO5kbOKEdaFdV1Q_6Rv8FNJfiCMtfR7HFwZshH6NjiHPpz4YS5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GMMkohJoQxQhCEFABAGCCMMYoYgQyySgAFqBKEAKYMUEwJBBERkhmHgBVCCCaAEARBAQkyjCihhCEIUsaAIRIgpIxwRBhgDBBgKAGEgIAwIMRVBDAiFAAACUAARAIoAABzRhAqiBCOCAWcIY4yAhgoFDBgBADACQqYUEIiRYhBwgCBiGDEGwQMMFo4QIiVCSFhBBBAQgKMIMIIQJBRQBLUiBECAs0EUYwphgxjSBhACRACIEGEIIgQZgASAnhBEDDGI2IcMYAIZ4QC3CgEEDGOAUUYUAIK4YETxBhAEAMSEEAA``

Response:

{"status": "ok", "results": []}
dufferzafar commented 8 years ago

AcoustID lookups only work for what's already in the database and I don't think anyone has ever submitted IDs of youtube videos before, so that method probably won't work!

yask123 commented 8 years ago

Damn :disappointed:

Only alternative I can think of is to do google search with song tittle and scrape meta data from websites ?

ssundarraj commented 8 years ago

@dufferzafar I think it might work for YouTube videos. As far as I know, it matches the fingerprint of the song. It doesn't really matter where you download it from as long as that song is in the database.

yask123 commented 8 years ago

@ssundarraj It didn't work, I tried multiple times with different songs downloaded from youtube.

gamegoofs2 commented 8 years ago

I found something the other day. It was called EchoNest. It might work. On Oct 14, 2015 8:49 AM, "Yask Srivastava" notifications@github.com wrote:

@ssundarraj https://github.com/ssundarraj It didn't work, I tried multiple times with different songs downloaded from youtube.

— Reply to this email directly or view it on GitHub https://github.com/yask123/Instant-Music-Downloader/issues/38#issuecomment-148040056 .

yask123 commented 8 years ago

Tried this hack to grab album name

album_name=''
        try:
            url = 'http://www.google.com/search?q='+qp(title)
            req = requests.get(url)
            response = req.content
            result=str(response)
            link_start=result.find('http://www.metrolyrics.com')
            link_end=result.find('html',link_start+1)
            link = result[link_start:link_end+4]
            lyrics_html = link
            a = requests.get(lyrics_html)
            html_doc=  a.content
            soup = BeautifulSoup(html_doc, 'html.parser')
            album_name = soup.find(id = "album-name-link").text
        except:
            print ('Album name not found')    

Tested multiple times with different songs, seems to work for most of them. It would work for songs which have their lyrics in metrolyrics.com. From there I am scraping the meta data. Eg: http://www.metrolyrics.com/21-guns-lyrics-green-day.html

from 21st Century Breakdown

yask123 commented 8 years ago

Pushed it to the source: bd2d28bff904bd3d5e27ab4c9984f5cc5ea70c6a

This will embed artist name, song title, album name, album art.

Have a look here: https://github.com/yask123/Instant-Music-Downloader/blob/master/instantmusic-0.1/bin/instantmusic#L123

Since I haven't updated the package yet, run $ sublwhich instantmusic``

Replace subl with whichever code editor you use, and replace all code with: https://github.com/yask123/Instant-Music-Downloader/blob/master/instantmusic-0.1/bin/instantmusic

yask123 commented 8 years ago

Updated package. Run pip install instantmusic --upgrade to try.

kniacdz
semaj commented 8 years ago

@yask123 I notice in the above picture the song has the last character cut off.

I am experiencing this too - the actual filename is fine but whenever I open it in any media player (Plex, iTunes, cmus) it's cut off. Any idea what that could be?

yask123 commented 8 years ago

@semaj Thanks for reporting. Yes this issue exists. It's a minor bug (Indexes for slicing text are not accurate). I'll fix this bug after my exams get over (5th December).