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.41k stars 9.96k forks source link

Unable to download shelf? #7415

Closed tantalate closed 8 years ago

tantalate commented 8 years ago

Hi, i would like to use this to download a shelf (playlists) like this page.

However, when I use youtube-dl -o './%(playlist_title)s/%(title)s-%(id)s.%(ext)s' "https://www.youtube.com/user/afigfigueira/playlists?sort=dd&view=50&shelf_id=6" to download it, it will download all the files the user have uploaded, and the %(playlist_title)s only gave a title like this Uploads from Arnaldo Pedro Figueira Figueira, not the real titles of the playlists.

Is shelf supported by now?

tantalate commented 8 years ago

it seems that shelf is not supported for now, so i wrote this little script to download all playlists in a shelf. Paste it here in case it may help someone.

import requests
import os
#from lxml import etree
from bs4 import BeautifulSoup

r = requests.get("http://www.youtube.com/user/afigfigueira/playlists?sort=dd&view=50&shelf_id=6")
#r = requests.get("https://www.youtube.com/watch?v=LTDmMI4VSCM&list=PLO9y7hOkmmSF2-_mB46a23K2UOkH5ic8T")

html = r.content

# tree = etree.HTML(html)
soup = BeautifulSoup(html, 'lxml')

lists = soup.find_all('a', class_="yt-uix-tile-link")

for lst in lists:
        print(lst.get('href'))
        os.system("youtube-dl -o '%(playlist)s/%(title)s.%(ext)s' " + "https://www.youtube.com" + lst.get('href'))
itamarAI commented 2 years ago

@tantalate I thought this was my saviour but I couldn't get it to work. Before I look elsewhere, I might just run what I'm after here to see if it's easily tweaked.

I'm looking to download just the subtitle files (vtt) from each video in each playlist on a shelf. I changed line 20 to read as follows:

os.system("youtube-dl -o --skip-download --all-subs " + "https://www.youtube.com" + lst.get('href'))

but it doesn't do anything, not even an error.

I'm looking at the URL with it's shelf ID and I can't help but notice it seems to be different which I'm wondering is the source of the problem.

This is the URL I'm trying to run it on: https://www.youtube.com/c/mitocw/playlists?view=50&sort=dd&shelf_id=3

I also had a look through the dev tool to find the item beautiful soup is looking for and it wasn't there so maybe youtube has also changed something?

any ideas? tyvm!