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

Switching to use yt-dlp as youtube-dl seems to have stalled #41

Closed
lenaxia opened this issue Aug 16, 2021 · 6 comments
Closed

Switching to use yt-dlp as youtube-dl seems to have stalled #41

lenaxia opened this issue Aug 16, 2021 · 6 comments

Comments

@lenaxia
Copy link

lenaxia commented Aug 16, 2021

a la ytdl-org/youtube-dl#29753 it seems youtube-dl may have stalled

It seems there are some throttling issues in youtube-dl anyway (ytdl-org/youtube-dl#29361) which I've been hitting a lot of.

So there's another drop in replacement for youtube-dl here: https://github.com/yt-dlp/yt-dlp and wanted to suggest switching to using that instead.

Cheers

@alexta69
Copy link
Owner

Thanks for the heads-up.
I've tried yt-dlp and it doesn't quite work as a drop-in, the download crashes, there must be something different there. I'll try to find time to debug this. If you have some time you're also welcome to try it out of course.. If I get to it first, I'll let you know.
Cheers!

@lenaxia
Copy link
Author

lenaxia commented Aug 18, 2021

I'm in the process of giving it a try as well, and likewise I also see the download crashing too. I'll see how far I can get to debug the crash.

@alexta69
Copy link
Owner

Have you tried the new version now, after I pushed the changes? it's supposed to work with yt-dlp now.
I did a little testing on it and it seems to work fine. Let me know if you're seeing problems with it.

@lenaxia
Copy link
Author

lenaxia commented Aug 19, 2021

Wow, that was fast. It works great. Looks like it defaults to webm format for download but thats something that can be managed on the user side.

Below are the changes I made. The first one outputs mp4 if you select best quality because Plex doesn't seem to be able to read video descriptions from .webm files. And the second block downloads the thumbnail and write the title and video description into the mp4 file itself for plex to pick up. Right now I'm just mounting a copy of the file with edits as a docker volume.

Edit: added so it does MP4 for all quality levels now

        if quality == 'best':
            self.format = f'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
        elif quality in ('1440p', '1080p', '720p', '480p'):
            res = quality[:-1]
            self.format = f'bestvideo[height<={res}][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'

Edit: Added subtitles download too

ret = yt_dlp.YoutubeDL(params={                                                                                                                                                                                                                                                                                                                                            
  ...
  'writethumbnail': True,                                                                                                                                                                                                                                                                                                                                                         
  'postprocessors': [{                                                                                                                                                                                                                                                                                                                                                                 
  'key': 'FFmpegMetadata'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
    }],                        
  'writesubtitles': True,
  'subtitle': '--write-sub --sub-lang en --sub-format vtt --convert-subtitles srt',                                                                                                                                                                                                                                                                                                                                                    
  ...
 }).download([self.info.url])

Edit: I should also note, I was seeing a bunch of errors for AtomicParsley in the logs when I enabled metadata writing, so I also mount a copy of AtomicParsley into the docker container. For the fullity of things, here's a copy of my docker compose:

  youtube-dl:
    image: "alexta69/metube"
    container_name: youtube-dl
    volumes:
      - "/mnt/downloads/[Plex Temp Library]/YouTube:/downloads"
      - $DOCKERDIR/youtube-dl/ytdl.py:/app/app/ytdl.py
      - $DOCKERDIR/youtube-dl/AtomicParsley:/usr/local/bin/AtomicParsley
    restart: unless-stopped
    user: "${PUID}:${PGID}"
    environment:
      - OUTPUT_TEMPLATE=%(upload_date)s - %(title)s [%(id)s].%(ext)s

@alexta69
Copy link
Owner

Thanks! I liked the idea of preferring mp4, so I pushed the qualities change now. Note that in your example it seems, unless I'm missing something, that when you select a resolution it might still download the highest one. I pushed this, I hope it's correct (haven't tested, to be frank):

        elif quality in ('1440p', '1080p', '720p', '480p'):
            res = quality[:-1]
            self.format = f'bestvideo[height<={res}][ext=mp4]+bestaudio[ext=m4a]/best[height<={res}][ext=mp4]/best[height<={res}]'

I won't push the subtitle changes, because I feel the use case is too narrow and also AtomicParsley seems to be archeological -- it was last updated in 2005...

Thanks for your ideas!

@lenaxia
Copy link
Author

lenaxia commented Aug 19, 2021

I thought the same when I put that line of code in but I tried downloading a 480p version and it downloaded the right one so I left it as is. Can always strip out the end of the line if it does cause issues later.

And yeah, the subtitles and AtomicParsley may cause issues for others so totally get not inculding them.

Happy to help! metube has been the best youtube-dl interface that I've found. It's simple and gets the job done well, so been super happy with it.

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

No branches or pull requests

2 participants