Giter VIP home page Giter VIP logo

Comments (7)

pncnmnp avatar pncnmnp commented on June 12, 2024 1

My apologies, I should have closely examined the code of ytmdl. Fortunately, there is a workaround for the above-mentioned issue: directly call the ytmdl.core.search method.

import ytmdl
args = ytmdl.main.arguments()
args.SONG_NAME = ["SONG_NAME"]
args.choice = 1
args.quiet = True

url, title = ytmdl.core.search(args.SONG_NAME[0], args)

The URL can then be utilized directly with yt-dlp. I will experiment with this and provide an update soon. Thank you.

Edit:

Code for the yt-dlp part:

import yt_dlp

ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    },
    {'key': 'FFmpegMetadata'},],
    'outtmpl': '%(title)s.%(ext)s',
}

with yt_dlp.YoutubeDL(ydl_opts) as ydl:
    error_code = ydl.download([url])

from ytmdl.

deepjyoti30 avatar deepjyoti30 commented on June 12, 2024 1

The above is correct. You can use the core functions directly and establish various functionalities. Moreover, I think the feature you requested is still a good one since the metadata that yt-dlp provides can be a fallback meta. It doesn't look good but it will be something.

The above yt-dlp code looks good. You can refer to how ytmdl is using yt-dlp by checking the ytmdl/yt.py file.

BTW, Phoenix10.1 looks like a good idea, will try it out!

from ytmdl.

pncnmnp avatar pncnmnp commented on June 12, 2024 1

@deepjyoti30 I just experimented with this code and it seems to work surprisingly well for our use cases, especially when compared to ytmdl’s metadata search.

import ytmdl
import yt_dlp
import eyed3
import glob
import os
import nltk

args = ytmdl.main.arguments()
args.SONG_NAME = ["YOUR_SONG_NAME"]
args.choice = 1
args.quiet = True

url, title = ytmdl.core.search(args.SONG_NAME[0], args)

ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    },
    {'key': 'FFmpegMetadata'},],
    'outtmpl': '%(title)s.%(ext)s',
}

with yt_dlp.YoutubeDL(ydl_opts) as ydl:
    error_code = ydl.download([url])

song_file = glob.glob("*.mp3")[0]
metadata = eyed3.load(song_file)
fetched_artist = metadata.tag.artist

os.remove(song_file)

infos = ytmdl.metadata.get_from_itunes(args.SONG_NAME[0])
most_accurate = sorted([info.json for info in infos[:10]], key=lambda x: nltk.edit_distance(x["artistName"], fetched_artist))[0]

print(most_accurate)

I will try to conduct more thorough testing on thousands of songs to verify this claim.

from ytmdl.

pncnmnp avatar pncnmnp commented on June 12, 2024 1

@deepjyoti30, we have successfully made the changes mentioned above to Phoenix 10.1.

If you plan on implementing these changes to ytmdl, check out pncnmnp/phoenix10.1#18 for inspiration.
Thank you for your help, and please feel free to ask any questions about our implementation.

from ytmdl.

deepjyoti30 avatar deepjyoti30 commented on June 12, 2024 1

@hariprasanths Support for youtube as a fallback for metadata is added in the above commit. I will include it in the next release.

from ytmdl.

pncnmnp avatar pncnmnp commented on June 12, 2024

@deepjyoti30, I feel confident in providing my comment on the above-mentioned code now.

TLDR; The code mentioned above appears to fetch metadata with about 29% more accuracy than the default logic of ytmdl.

I began by searching for datasets containing song titles and artist names. I found an excellent one on Kaggle: Top Spotify songs from 2010-2019 - BY YEAR.

Thus, I made minor enhancements to the aforementioned script and compared it to the metadata created by ytmdl.main.main.

Using the suggested script resulted in 82.8% accuracy, whereas ytmdl had about 54%. This finding aligns with our observations on Phoenix10.1, where 1/4 to 1/3 of all songs display incorrect metadata.

The dataset comprises roughly 600 songs, although I couldn't test the entire set as it was quite slow. Nonetheless, after analyzing 250 songs, I obtained the above results that should provide a suitable estimate.

Based on this experiment, I am confident that the best action for Phoenix10.1 is to utilize --add-metadata with yt-dlp to collect the song's actual metadata. Following this, we will extract further information from itunespy using an edit_distance based method.

We will continue to use ytmdl.core.search as it has proven quite practical.

Here is the code and data for the entire experiment.

from ytmdl.

hariprasanths avatar hariprasanths commented on June 12, 2024

Failling back to yt-dlp's metadata when metadata fetch errors out would help a lot. I would prefer to have an option to not skip a track altogether when metadata fetch fails.

from ytmdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.