ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.56k stars 9.97k forks source link

Download videos from google search #30576

Open gonprats opened 2 years ago

gonprats commented 2 years ago

Checklist

Description

With the latest google search versions, one can look up "NFL" (for example), and the schedules, players and teams pop-up as well as (and this is what I'm suggesting to implement) previews or highlights. When trying to download them from the Google page, it does not recognizes it, the user needs to get into the actual video (youtube in most cases) to get it. Implementing this would mean much faster access to videos and the users not having to navigate several layers of webpages to download them. I tried creating a general "google extractor" but couldn't manage to do it. Other option I thought about but could not put into practice was to handle that webpage forwarding (google search -> youtube) within the program

dirkf commented 2 years ago

You'll need to open the search page with JS disabled to see anything like what yt-dl would see. With any luck, the video page will be the value of a parameter, eg q, in the link in the search page.

Some examples of search pages, video links in the pages and the linked videos could help this along.

pukkandan commented 2 years ago

There is already a google search extractor. It is broken atm, but easy to fix. See https://github.com/yt-dlp/yt-dlp/commit/c533c89ce1d6965d8575413738d76a5bf9e2de59

dirkf commented 2 years ago

Thanks.

First see https://github.com/ytdl-org/youtube-dl/issues/29724 and the issue linked from it, and the manual, especially the section linked from there.

From the comment, possibly the linked fork has fixed the extractor and you will just need to back-port the change.

Once you have a branch working in your fork, you can make a Pull Request against the yt-dl repo.

Mamadou442 commented 2 years ago

how do i back-port the change ? I just search what it mean, should it mean that i should Copy paste the commit and make the PR myself ?

Mamadou442 commented 2 years ago

i make a fork myself so I doing to work like that (use the commit of @pukkandan )

dirkf commented 2 years ago

One way is to use a tool like meld, a graphical difference editor. Check out yt-dl and yt-dlp, load the yt-dlp extractor into the editor and load the yt-dl extractor into the right-hand pane. Then you can go through the differences and decide whether the yt-dlp change should applied directly, modified or ignored. Some changes will be specific to yt-dlp and need to be adapted so as to run on both Python 2 and 3. For example, the linked commit includes these lines that will fail in Python 2

                'http://www.google.com/search', f'gvsearch:{query}',
                note=f'Downloading result page {pagenum + 1}',

You'll need to change this in some way, say:

                'http://www.google.com/search', 'gvsearch:' + query,
                note='Downloading result page %d' % (pagenum + 1, ),

Some IDE plug-in or judicious use of vi and diff could achieve the same result.

If there is a specific change, a commit or set of commits, that should be applied, you can use git magic to apply such commits while preserving the commit details. In GH you can add .patch to commit and PR URLs to generate a patch file that you can pass to the git am command: to make the patch applicable you first have to edit it to replace the yt_dlp/ in pathnames with youtube_dl/. After applying the patch to your branch you can make any additional changes in your own subsequent commit. Eventually when this gets merged we would probably squash the commits in the PR so that the resulting commit appears as Co-authored by: all the people whose commits are included.

As above, test the modified extractor in your patch branch (there's a small test in the linked commit). Then push the branch to your yt-dl fork. You should be able to enable the server-side tests that ensure your changes work in a variety of supported environments. Fix any issues and then create a PR against our youtube_dl repo.

K-web04 commented 1 year ago

Hey,Can I work on this issue

dirkf commented 1 year ago

Please do.