marin-m / SongRec

An open-source Shazam client for Linux, written in Rust.
GNU General Public License v3.0
1.35k stars 103 forks source link

getting ID3 tag #62

Open alfredjophy opened 3 years ago

alfredjophy commented 3 years ago

is there a way to get ID3 tag as a json from either the shazam api used or as a function in songrec it would really help a lot of people using songrec in scripts to recongize songs , rename and add metadata

thanks

marin-m commented 3 years ago

Hello,

Does something like this not fit the need?

json_data="$(songrec audio-file-to-recognized-song "${MY_SONG_FILE_PATH}.mp3")"
echo "${json_data}" | jq ".track.genres"
echo "${json_data}" | jq ".track.sections[0]"

If not, what is missing? Is there a standard JSON representation for ID3 I don't know about? Or would you want to recognize audio from the microphone through the command line or something like that?

Regards,

alfredjophy commented 3 years ago

im not sure if there is standard json for ID3 , its just that the way metadata is in the JSON that songrec(i.e shazam gives) is too obscure to get info like artist name , cover art , release year , etc.

Iytmdl's metadata funtions for spotify seems like a easy way to get a more complete metadata output(i will try that later)

marin-m commented 3 years ago

its just that the way metadata is in the JSON that songrec(i.e shazam gives) is too obscure to get info like artist name , cover art , release year , etc.

Here is the output of the command that I pasted above for a random song:

$ json_data="$(songrec audio-file-to-recognized-song "/home/marin/Jorrdee - Intégrale (2011-2017) [Rap] .mp3/La Nuit Avant le Jour (2015)/15 - Éternel.mp3" )"

$ echo "${json_data}" | jq ".track.genres"
{
  "primary": "Hip-Hop/Rap"
}

$ echo "${json_data}" | jq ".track.sections[0]"
{
  "metadata": [
    {
      "text": "La Nuit Avant Le Jour",
      "title": "Album"
    },
    {
      "text": "DANNY",
      "title": "Label"
    },
    {
      "text": "2019",
      "title": "Released"
    }
  ],
  "metapages": [
    {
      "caption": "Jorrdee",
      "image": "https://is1-ssl.mzstatic.com/image/thumb/Features115/v4/95/82/d2/9582d242-883c-32ee-a8ca-8f91861c73a8/mzl.usxralaf.jpg/800x800cc.jpg"
    },
    {
      "caption": "Eternel",
      "image": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/80/a1/43/80a14348-9d68-f813-7d9b-76045f974d45/artwork.jpg/400x400cc.jpg"
    }
  ],
  "tabname": "Song",
  "type": "SONG"
}

Is this really hard to understand? You obtain almost all the basic ID3 tags you can expect for the song, including cover art, genre, artist name, album name, track name, release year, excluding the track number (and Spotify/Deezer/Apple Music URLs are present for fetching any extra metadata if absolutely needed).

Iytmdl's metadata funtions for spotify seems like a easy way to get a more complete metadata output

"Iytmdl spotify" yields no Google results, maybe a typo?

Regards,

alfredjophy commented 3 years ago

sorry , its ytmdl , thats on github it uses spotify for getting metadata

uunnxx commented 2 years ago

Or would you want to recognize audio from the microphone through the command line or something like that?

Is this possible ?

Can we launch songrec from the cli and get metadata of recognized audio from the microphone as json ? Can we get json using cli version of songrec?

OR:

Just output to stdout or write(or append as a stack) to a file ? So we could, for example, output filename to a file as Artist - Title of the track

> songrec --listen --output ~/recognised_songs.txt