Skip to content

Commit 416c7fc

Browse files
committed
Add documentation about supported sites (Fixes #4503)
1 parent 7fc2cd8 commit 416c7fc

File tree

6 files changed

+567
-3
lines changed

6 files changed

+567
-3
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
all: youtube-dl README.md CONTRIBUTING.md README.txt youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish
1+
all: youtube-dl README.md CONTRIBUTING.md README.txt youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish supportedsites
22

33
clean:
44
rm -rf youtube-dl.1.temp.md youtube-dl.1 youtube-dl.bash-completion README.txt MANIFEST build/ dist/ .coverage cover/ youtube-dl.tar.gz youtube-dl.zsh youtube-dl.fish *.dump *.part *.info.json CONTRIBUTING.md.tmp
@@ -50,7 +50,7 @@ offlinetest: codetest
5050

5151
tar: youtube-dl.tar.gz
5252

53-
.PHONY: all clean install test tar bash-completion pypi-files zsh-completion fish-completion ot offlinetest codetest
53+
.PHONY: all clean install test tar bash-completion pypi-files zsh-completion fish-completion ot offlinetest codetest supportedsites
5454

5555
pypi-files: youtube-dl.bash-completion README.txt youtube-dl.1 youtube-dl.fish
5656

@@ -68,6 +68,9 @@ README.md: youtube_dl/*.py youtube_dl/*/*.py
6868
CONTRIBUTING.md: README.md
6969
python devscripts/make_contributing.py README.md CONTRIBUTING.md
7070

71+
supportedsites:
72+
python devscripts/make_supportedsites.py docs/supportedsites.md
73+
7174
README.txt: README.md
7275
pandoc -f markdown -t plain README.md -o README.txt
7376

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ Since June 2012 (#342) youtube-dl is packed as an executable zipfile, simply unz
449449

450450
To run the exe you need to install first the [Microsoft Visual C++ 2008 Redistributable Package](http://www.microsoft.com/en-us/download/details.aspx?id=29).
451451

452+
### How can I detect whether a given URL is supported by youtube-dl?
453+
454+
For one, have a look at the [list of supported sites](docs/supportedsites). Note that it can sometimes happen that the site changes its URL scheme (say, from http://example.com/v/1234567 to http://example.com/v/1234567 ) and youtube-dl reports an URL of a service in that list as unsupported. In that case, simply report a bug.
455+
456+
It is *not* possible to detect whether a URL is supported or not. That's because youtube-dl contains a generic extractor which maches **all** URLs. You may be tempted to disable, exclude, or remove the generic extractor, but the generic extractor not only allows users to extract videos from lots of websites that embed a video from another service, but may also be used to extract video from a service that it's hosting itself. Therefore, we neither recommend nor support disabling, excluding, or removing the generic extractor.
457+
458+
If you want to find out, simply call youtube-dl. If you get no videos back, chances are the URL is either not referring to a video or unsupported. You can find out which by examining the output (if you run youtube-dl on the console) or catching an `UnsupportedError` exception if you run it from a Python program.
459+
452460
# DEVELOPER INSTRUCTIONS
453461

454462
Most users do not need to build youtube-dl and can [download the builds](http://rg3.github.io/youtube-dl/download.html) or get them from their distribution.

devscripts/make_supportedsites.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
from __future__ import unicode_literals
3+
4+
import io
5+
import optparse
6+
import os
7+
import sys
8+
9+
10+
# Import youtube_dl
11+
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
12+
sys.path.append(ROOT_DIR)
13+
import youtube_dl
14+
15+
16+
def main():
17+
parser = optparse.OptionParser(usage='%prog OUTFILE.md')
18+
options, args = parser.parse_args()
19+
if len(args) != 1:
20+
parser.error('Expected an output filename')
21+
22+
outfile, = args
23+
24+
def gen_ies_md(ies):
25+
for ie in ies:
26+
ie_md = '**{}**'.format(ie.IE_NAME)
27+
ie_desc = getattr(ie, 'IE_DESC', None)
28+
if ie_desc is False:
29+
continue
30+
if ie_desc is not None:
31+
ie_md += ': {}'.format(ie.IE_DESC)
32+
if not ie.working():
33+
ie_md += ' (Currently broken)'
34+
yield ie_md
35+
36+
ies = sorted(youtube_dl.gen_extractors(), key=lambda i: i.IE_NAME.lower())
37+
out = '# Supported sites\n' + ''.join(
38+
' - ' + md + '\n'
39+
for md in gen_ies_md(ies))
40+
41+
with io.open(outfile, 'w', encoding='utf-8') as outf:
42+
outf.write(out)
43+
44+
if __name__ == '__main__':
45+
main()

0 commit comments

Comments
 (0)