From 9dc487f48b50767cf540fa36c3de2c386fd74c04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rog=C3=A9rio=20Brito?= Date: Fri, 24 Jun 2016 22:51:49 -0300 Subject: [PATCH 1/1] Imported Upstream version 2016.06.25 --- .github/ISSUE_TEMPLATE.md | 58 + .github/ISSUE_TEMPLATE_tmpl.md | 58 + .gitignore | 43 + .travis.yml | 21 + AUTHORS | 177 ++ CONTRIBUTING.md | 158 ++ Makefile | 26 +- README.md | 158 +- README.txt | 1410 ---------- devscripts/buildserver.py | 75 +- devscripts/create-github-release.py | 111 + devscripts/install_srelay.sh | 8 + devscripts/lazy_load_template.py | 19 + devscripts/make_issue_template.py | 29 + devscripts/make_lazy_extractors.py | 98 + devscripts/prepare_manpage.py | 61 +- devscripts/release.sh | 57 +- docs/supportedsites.md | 148 +- setup.cfg | 6 + setup.py | 80 +- test/helper.py | 15 +- test/swftests/ArrayAccess.swf | Bin 609 -> 0 bytes test/swftests/ClassCall.swf | Bin 581 -> 0 bytes test/swftests/ClassConstruction.swf | Bin 553 -> 0 bytes test/swftests/ConstArrayAccess.swf | Bin 627 -> 0 bytes test/swftests/ConstantInt.swf | Bin 516 -> 0 bytes test/swftests/DictCall.swf | Bin 545 -> 0 bytes test/swftests/EqualsOperator.swf | Bin 511 -> 0 bytes test/swftests/LocalVars.swf | Bin 517 -> 0 bytes test/swftests/MemberAssignment.swf | Bin 558 -> 0 bytes test/swftests/NeOperator.swf | Bin 535 -> 0 bytes test/swftests/PrivateCall.swf | Bin 595 -> 0 bytes test/swftests/PrivateVoidCall.swf | Bin 600 -> 0 bytes test/swftests/StaticAssignment.swf | Bin 516 -> 0 bytes test/swftests/StaticConstArrayAccess.swf | Bin 575 -> 0 bytes test/swftests/StaticRetrieval.swf | Bin 516 -> 0 bytes test/swftests/StringBasics.swf | Bin 522 -> 0 bytes test/swftests/StringCharCodeAt.swf | Bin 556 -> 0 bytes test/swftests/StringConversion.swf | Bin 532 -> 0 bytes test/swftests/StringFunctions.swf | Bin 519 -> 0 bytes test/test_InfoExtractor.py | 10 + test/test_YoutubeDL.py | 8 + test/test_compat.py | 41 +- test/test_http.py | 60 +- test/test_socks.py | 118 + test/test_utils.py | 174 +- test/test_youtube_lists.py | 2 +- test/video-vid.mp4 | Bin 14 -> 0 bytes tox.ini | 14 + youtube-dl | Bin 1122987 -> 0 bytes youtube-dl.1 | 2001 -------------- youtube-dl.bash-completion | 29 - youtube-dl.fish | 146 - youtube-dl.plugin.zsh | 24 + youtube-dl.zsh | 28 - youtube_dl/YoutubeDL.py | 132 +- youtube_dl/__init__.py | 37 +- youtube_dl/compat.py | 2365 ++++++++++++++++- youtube_dl/downloader/__init__.py | 24 +- youtube_dl/downloader/common.py | 11 +- youtube_dl/downloader/dash.py | 42 +- youtube_dl/downloader/external.py | 137 +- youtube_dl/downloader/f4m.py | 62 +- youtube_dl/downloader/fragment.py | 12 +- youtube_dl/downloader/hls.py | 184 +- youtube_dl/downloader/rtsp.py | 2 + youtube_dl/extractor/__init__.py | 984 +------ youtube_dl/extractor/abc.py | 2 +- youtube_dl/extractor/abc7news.py | 1 + youtube_dl/extractor/abcnews.py | 135 + youtube_dl/extractor/acast.py | 38 +- youtube_dl/extractor/addanime.py | 6 +- youtube_dl/extractor/adobetv.py | 5 +- youtube_dl/extractor/aenetworks.py | 39 +- youtube_dl/extractor/afreecatv.py | 133 + youtube_dl/extractor/aftonbladet.py | 6 +- youtube_dl/extractor/aljazeera.py | 20 +- youtube_dl/extractor/amp.py | 8 +- youtube_dl/extractor/animeondemand.py | 168 +- youtube_dl/extractor/anvato.py | 224 ++ youtube_dl/extractor/aol.py | 145 +- youtube_dl/extractor/appletrailers.py | 53 +- youtube_dl/extractor/ard.py | 41 +- youtube_dl/extractor/arte.py | 279 +- youtube_dl/extractor/atresplayer.py | 12 +- youtube_dl/extractor/audimedia.py | 19 +- youtube_dl/extractor/audioboom.py | 66 + youtube_dl/extractor/audiomack.py | 15 +- youtube_dl/extractor/azubu.py | 22 +- youtube_dl/extractor/baidu.py | 2 +- youtube_dl/extractor/bambuser.py | 10 +- youtube_dl/extractor/bandcamp.py | 8 +- youtube_dl/extractor/bbc.py | 116 +- youtube_dl/extractor/beeg.py | 33 +- youtube_dl/extractor/behindkink.py | 2 +- youtube_dl/extractor/bet.py | 93 +- youtube_dl/extractor/bilibili.py | 205 +- youtube_dl/extractor/biobiochiletv.py | 86 + youtube_dl/extractor/biqle.py | 39 + youtube_dl/extractor/bleacherreport.py | 10 +- youtube_dl/extractor/bloomberg.py | 3 + youtube_dl/extractor/bokecc.py | 60 + youtube_dl/extractor/bpb.py | 2 +- youtube_dl/extractor/br.py | 9 +- youtube_dl/extractor/bravotv.py | 31 + youtube_dl/extractor/breakcom.py | 2 +- youtube_dl/extractor/brightcove.py | 191 +- youtube_dl/extractor/byutv.py | 4 +- youtube_dl/extractor/c56.py | 22 +- youtube_dl/extractor/camdemy.py | 8 +- youtube_dl/extractor/camwithher.py | 87 + youtube_dl/extractor/canalplus.py | 80 +- youtube_dl/extractor/carambatv.py | 88 + youtube_dl/extractor/cbc.py | 96 +- youtube_dl/extractor/cbs.py | 81 +- .../extractor/{cnet.py => cbsinteractive.py} | 60 +- youtube_dl/extractor/cbslocal.py | 84 + youtube_dl/extractor/cbsnews.py | 50 +- youtube_dl/extractor/cbssports.py | 40 +- youtube_dl/extractor/ccc.py | 111 +- youtube_dl/extractor/cda.py | 98 + youtube_dl/extractor/ceskatelevize.py | 47 +- youtube_dl/extractor/channel9.py | 125 +- youtube_dl/extractor/chaturbate.py | 1 + youtube_dl/extractor/cinemassacre.py | 107 - youtube_dl/extractor/cliphunter.py | 2 +- youtube_dl/extractor/cliprs.py | 90 + youtube_dl/extractor/clipsyndicate.py | 2 +- youtube_dl/extractor/closertotruth.py | 92 + youtube_dl/extractor/cloudy.py | 8 +- youtube_dl/extractor/clubic.py | 2 +- youtube_dl/extractor/cnbc.py | 36 + youtube_dl/extractor/collegehumor.py | 101 - youtube_dl/extractor/comcarcoff.py | 13 +- youtube_dl/extractor/comedycentral.py | 11 +- youtube_dl/extractor/common.py | 303 ++- youtube_dl/extractor/commonprotocols.py | 36 + youtube_dl/extractor/condenast.py | 6 +- youtube_dl/extractor/coub.py | 143 + youtube_dl/extractor/crunchyroll.py | 56 +- youtube_dl/extractor/cspan.py | 2 +- youtube_dl/extractor/ctsnews.py | 2 +- youtube_dl/extractor/cwtv.py | 6 +- youtube_dl/extractor/dailymail.py | 61 + youtube_dl/extractor/daum.py | 6 +- youtube_dl/extractor/dcn.py | 56 +- youtube_dl/extractor/dctp.py | 2 +- youtube_dl/extractor/deezer.py | 4 +- youtube_dl/extractor/defense.py | 2 +- youtube_dl/extractor/democracynow.py | 45 +- youtube_dl/extractor/dfb.py | 34 +- youtube_dl/extractor/discovery.py | 45 +- youtube_dl/extractor/dispeak.py | 114 + youtube_dl/extractor/douyutv.py | 57 +- youtube_dl/extractor/dplay.py | 154 +- youtube_dl/extractor/dramafever.py | 4 +- youtube_dl/extractor/dreisat.py | 2 +- youtube_dl/extractor/dump.py | 39 - youtube_dl/extractor/dvtv.py | 2 +- youtube_dl/extractor/dw.py | 108 + youtube_dl/extractor/eagleplatform.py | 35 +- youtube_dl/extractor/ebaumsworld.py | 4 +- youtube_dl/extractor/echomsk.py | 2 +- youtube_dl/extractor/elpais.py | 31 +- youtube_dl/extractor/engadget.py | 25 +- youtube_dl/extractor/eporner.py | 12 +- youtube_dl/extractor/eroprofile.py | 4 +- youtube_dl/extractor/espn.py | 6 +- youtube_dl/extractor/exfm.py | 2 +- youtube_dl/extractor/extractors.py | 1064 ++++++++ youtube_dl/extractor/eyedotv.py | 64 + youtube_dl/extractor/facebook.py | 111 +- youtube_dl/extractor/fc2.py | 7 +- youtube_dl/extractor/fczenit.py | 33 +- youtube_dl/extractor/firstpost.py | 2 +- youtube_dl/extractor/firsttv.py | 139 +- youtube_dl/extractor/fivemin.py | 53 +- youtube_dl/extractor/fktv.py | 2 +- youtube_dl/extractor/flickr.py | 30 +- youtube_dl/extractor/footyroom.py | 2 +- youtube_dl/extractor/formula1.py | 26 + youtube_dl/extractor/fox.py | 3 + youtube_dl/extractor/foxgay.py | 2 +- youtube_dl/extractor/foxnews.py | 12 +- youtube_dl/extractor/foxsports.py | 20 +- youtube_dl/extractor/franceinter.py | 2 +- youtube_dl/extractor/francetv.py | 56 +- youtube_dl/extractor/freespeech.py | 2 +- youtube_dl/extractor/freevideo.py | 2 +- youtube_dl/extractor/funimation.py | 53 +- youtube_dl/extractor/funnyordie.py | 4 +- youtube_dl/extractor/gameinformer.py | 31 +- youtube_dl/extractor/gamekings.py | 2 +- youtube_dl/extractor/gamespot.py | 93 +- youtube_dl/extractor/gamestar.py | 2 +- youtube_dl/extractor/gametrailers.py | 62 - youtube_dl/extractor/gazeta.py | 12 +- youtube_dl/extractor/gdcvault.py | 110 +- youtube_dl/extractor/generic.py | 410 ++- youtube_dl/extractor/glide.py | 31 +- youtube_dl/extractor/godtv.py | 66 + youtube_dl/extractor/googledrive.py | 12 +- youtube_dl/extractor/goshgay.py | 6 +- youtube_dl/extractor/gputechconf.py | 36 +- youtube_dl/extractor/groupon.py | 35 +- youtube_dl/extractor/hbo.py | 122 + youtube_dl/extractor/hearthisat.py | 40 +- youtube_dl/extractor/hotnewhiphop.py | 6 +- youtube_dl/extractor/howcast.py | 4 +- youtube_dl/extractor/howstuffworks.py | 20 +- youtube_dl/extractor/huffpost.py | 36 +- youtube_dl/extractor/hypem.py | 6 +- youtube_dl/extractor/imdb.py | 47 +- youtube_dl/extractor/indavideo.py | 5 +- youtube_dl/extractor/infoq.py | 31 +- youtube_dl/extractor/instagram.py | 101 +- youtube_dl/extractor/internetvideoarchive.py | 118 +- youtube_dl/extractor/iprima.py | 44 +- youtube_dl/extractor/iqiyi.py | 85 +- youtube_dl/extractor/ivideon.py | 4 +- youtube_dl/extractor/izlesene.py | 7 +- youtube_dl/extractor/jadorecettepub.py | 47 - youtube_dl/extractor/jeuxvideo.py | 4 +- youtube_dl/extractor/jwplatform.py | 121 +- youtube_dl/extractor/kaltura.py | 71 +- youtube_dl/extractor/karaoketv.py | 58 +- youtube_dl/extractor/karrierevideos.py | 7 +- youtube_dl/extractor/khanacademy.py | 4 +- youtube_dl/extractor/kontrtube.py | 2 +- youtube_dl/extractor/ku6.py | 2 +- youtube_dl/extractor/kusi.py | 99 + youtube_dl/extractor/kuwo.py | 131 +- youtube_dl/extractor/laola1tv.py | 42 +- youtube_dl/extractor/learnr.py | 33 + youtube_dl/extractor/lecture2go.py | 17 +- youtube_dl/extractor/{letv.py => leeco.py} | 118 +- youtube_dl/extractor/libraryofcongress.py | 143 + youtube_dl/extractor/lifenews.py | 167 +- youtube_dl/extractor/limelight.py | 68 +- youtube_dl/extractor/litv.py | 137 + youtube_dl/extractor/liveleak.py | 17 +- youtube_dl/extractor/livestream.py | 15 +- youtube_dl/extractor/localnews8.py | 47 + youtube_dl/extractor/lrt.py | 1 + youtube_dl/extractor/lynda.py | 153 +- youtube_dl/extractor/m6.py | 2 +- youtube_dl/extractor/mailru.py | 6 +- youtube_dl/extractor/makerschannel.py | 40 + youtube_dl/extractor/malemotion.py | 46 - youtube_dl/extractor/matchtv.py | 26 +- youtube_dl/extractor/mdr.py | 13 +- youtube_dl/extractor/metacafe.py | 9 +- youtube_dl/extractor/metacritic.py | 14 +- youtube_dl/extractor/mgtv.py | 64 + .../extractor/microsoftvirtualacademy.py | 192 ++ youtube_dl/extractor/minhateca.py | 4 +- youtube_dl/extractor/ministrygrid.py | 34 +- youtube_dl/extractor/minoto.py | 56 + youtube_dl/extractor/mit.py | 4 +- youtube_dl/extractor/mitele.py | 55 +- youtube_dl/extractor/mixcloud.py | 267 +- youtube_dl/extractor/mnet.py | 81 + youtube_dl/extractor/moevideo.py | 4 +- youtube_dl/extractor/moniker.py | 4 +- youtube_dl/extractor/mooshare.py | 110 - youtube_dl/extractor/motherless.py | 99 +- youtube_dl/extractor/motorsport.py | 2 +- youtube_dl/extractor/movieclips.py | 43 +- youtube_dl/extractor/mtv.py | 21 +- youtube_dl/extractor/musicplayon.py | 59 +- youtube_dl/extractor/muzu.py | 65 - youtube_dl/extractor/mwave.py | 28 +- youtube_dl/extractor/myspace.py | 80 +- youtube_dl/extractor/myspass.py | 2 +- youtube_dl/extractor/myvideo.py | 6 +- youtube_dl/extractor/myvidster.py | 2 +- youtube_dl/extractor/nationalgeographic.py | 89 +- youtube_dl/extractor/naver.py | 6 +- youtube_dl/extractor/nba.py | 101 +- youtube_dl/extractor/nbc.py | 222 +- youtube_dl/extractor/ndtv.py | 40 +- youtube_dl/extractor/nerdist.py | 80 - youtube_dl/extractor/neteasemusic.py | 22 +- youtube_dl/extractor/newgrounds.py | 21 +- youtube_dl/extractor/newstube.py | 43 +- youtube_dl/extractor/nextmedia.py | 6 +- youtube_dl/extractor/nextmovie.py | 4 +- youtube_dl/extractor/nfb.py | 113 +- youtube_dl/extractor/nhl.py | 104 +- youtube_dl/extractor/nick.py | 28 +- youtube_dl/extractor/niconico.py | 8 +- youtube_dl/extractor/noco.py | 6 +- youtube_dl/extractor/normalboots.py | 20 +- youtube_dl/extractor/nova.py | 2 +- youtube_dl/extractor/novamov.py | 52 +- youtube_dl/extractor/nowness.py | 11 +- youtube_dl/extractor/noz.py | 46 +- youtube_dl/extractor/npr.py | 6 +- youtube_dl/extractor/nrk.py | 449 ++-- youtube_dl/extractor/ntvru.py | 2 +- youtube_dl/extractor/nuvid.py | 44 +- youtube_dl/extractor/nytimes.py | 9 +- youtube_dl/extractor/odnoklassniki.py | 40 +- youtube_dl/extractor/once.py | 42 + youtube_dl/extractor/onionstudios.py | 21 +- youtube_dl/extractor/ooyala.py | 122 +- youtube_dl/extractor/openload.py | 130 + youtube_dl/extractor/ora.py | 9 +- youtube_dl/extractor/orf.py | 7 +- youtube_dl/extractor/patreon.py | 2 +- youtube_dl/extractor/pbs.py | 63 +- youtube_dl/extractor/people.py | 32 + youtube_dl/extractor/periscope.py | 53 +- youtube_dl/extractor/philharmoniedeparis.py | 2 +- youtube_dl/extractor/photobucket.py | 2 +- youtube_dl/extractor/planetaplay.py | 61 - youtube_dl/extractor/played.py | 4 +- youtube_dl/extractor/playtvak.py | 4 +- youtube_dl/extractor/playwire.py | 39 +- youtube_dl/extractor/pluralsight.py | 21 +- youtube_dl/extractor/porn91.py | 17 +- youtube_dl/extractor/pornhd.py | 60 +- youtube_dl/extractor/pornhub.py | 80 +- youtube_dl/extractor/pornovoisines.py | 2 +- youtube_dl/extractor/presstv.py | 74 + youtube_dl/extractor/primesharetv.py | 4 +- youtube_dl/extractor/promptfile.py | 4 +- youtube_dl/extractor/prosiebensat1.py | 10 +- youtube_dl/extractor/puls4.py | 2 +- youtube_dl/extractor/pyvideo.py | 8 +- youtube_dl/extractor/qqmusic.py | 10 +- youtube_dl/extractor/quickvid.py | 54 - youtube_dl/extractor/r7.py | 95 +- youtube_dl/extractor/radiocanada.py | 130 + youtube_dl/extractor/radiojavan.py | 2 +- youtube_dl/extractor/rai.py | 4 +- youtube_dl/extractor/redtube.py | 60 +- youtube_dl/extractor/restudy.py | 1 + youtube_dl/extractor/reuters.py | 69 + youtube_dl/extractor/revision3.py | 165 +- youtube_dl/extractor/rice.py | 116 + youtube_dl/extractor/ringtv.py | 2 +- youtube_dl/extractor/rockstargames.py | 69 + youtube_dl/extractor/rottentomatoes.py | 24 +- youtube_dl/extractor/rtbf.py | 62 +- youtube_dl/extractor/rte.py | 12 +- youtube_dl/extractor/rtlnl.py | 68 +- youtube_dl/extractor/rtve.py | 42 +- youtube_dl/extractor/rtvnh.py | 1 + youtube_dl/extractor/ruhd.py | 2 +- youtube_dl/extractor/rutube.py | 6 +- youtube_dl/extractor/rutv.py | 8 +- youtube_dl/extractor/safari.py | 106 +- youtube_dl/extractor/sbs.py | 35 +- youtube_dl/extractor/scivee.py | 1 + youtube_dl/extractor/screencast.py | 13 +- youtube_dl/extractor/screencastomatic.py | 36 +- youtube_dl/extractor/screenjunkies.py | 2 +- youtube_dl/extractor/screenwavemedia.py | 20 +- youtube_dl/extractor/seeker.py | 57 + youtube_dl/extractor/senateisvp.py | 2 +- youtube_dl/extractor/sendtonews.py | 86 + youtube_dl/extractor/sexu.py | 25 +- youtube_dl/extractor/shahid.py | 5 +- youtube_dl/extractor/shared.py | 6 +- youtube_dl/extractor/sharesix.py | 4 +- youtube_dl/extractor/sina.py | 124 +- youtube_dl/extractor/smotri.py | 6 +- youtube_dl/extractor/sohu.py | 4 +- youtube_dl/extractor/soundcloud.py | 11 +- youtube_dl/extractor/space.py | 38 - youtube_dl/extractor/spankwire.py | 22 +- youtube_dl/extractor/sport5.py | 2 +- youtube_dl/extractor/sportbox.py | 33 +- youtube_dl/extractor/sportschau.py | 38 + youtube_dl/extractor/ssa.py | 2 +- youtube_dl/extractor/streamcloud.py | 43 +- youtube_dl/extractor/streetvoice.py | 8 +- youtube_dl/extractor/svt.py | 120 +- youtube_dl/extractor/sztvhu.py | 2 +- youtube_dl/extractor/tagesschau.py | 328 ++- youtube_dl/extractor/tdslifeway.py | 33 + youtube_dl/extractor/teachingchannel.py | 3 +- youtube_dl/extractor/teamcoco.py | 4 +- youtube_dl/extractor/ted.py | 68 +- youtube_dl/extractor/tele13.py | 2 +- youtube_dl/extractor/telebruxelles.py | 14 +- youtube_dl/extractor/telecinco.py | 5 +- youtube_dl/extractor/telegraaf.py | 58 +- youtube_dl/extractor/telewebion.py | 55 + youtube_dl/extractor/tenplay.py | 90 - youtube_dl/extractor/tf1.py | 2 +- youtube_dl/extractor/theonion.py | 63 - youtube_dl/extractor/theplatform.py | 148 +- youtube_dl/extractor/thescene.py | 52 + youtube_dl/extractor/thesixtyone.py | 6 +- youtube_dl/extractor/thestar.py | 35 + youtube_dl/extractor/threeqsdn.py | 139 + youtube_dl/extractor/thvideo.py | 2 +- youtube_dl/extractor/tinypic.py | 2 +- youtube_dl/extractor/tlc.py | 35 +- youtube_dl/extractor/tnaflix.py | 56 +- youtube_dl/extractor/toypics.py | 2 +- youtube_dl/extractor/traileraddict.py | 2 +- youtube_dl/extractor/trollvids.py | 2 +- youtube_dl/extractor/tubitv.py | 56 +- youtube_dl/extractor/tudou.py | 41 +- youtube_dl/extractor/tumblr.py | 30 +- youtube_dl/extractor/tunein.py | 9 +- youtube_dl/extractor/tv2.py | 4 +- youtube_dl/extractor/tv3.py | 34 + youtube_dl/extractor/tvc.py | 4 +- youtube_dl/extractor/tvigle.py | 8 +- youtube_dl/extractor/tvp.py | 106 +- youtube_dl/extractor/tvplay.py | 2 +- youtube_dl/extractor/twentyfourvideo.py | 3 +- youtube_dl/extractor/twentymin.py | 23 +- youtube_dl/extractor/twitch.py | 109 +- youtube_dl/extractor/twitter.py | 219 +- youtube_dl/extractor/ubu.py | 57 - youtube_dl/extractor/udemy.py | 256 +- youtube_dl/extractor/udn.py | 62 +- youtube_dl/extractor/unistra.py | 3 +- youtube_dl/extractor/usatoday.py | 48 + youtube_dl/extractor/ustream.py | 16 +- youtube_dl/extractor/ustudio.py | 125 + youtube_dl/extractor/varzesh3.py | 48 +- youtube_dl/extractor/vbox7.py | 10 +- youtube_dl/extractor/veoh.py | 3 +- youtube_dl/extractor/vessel.py | 32 +- youtube_dl/extractor/vesti.py | 2 +- youtube_dl/extractor/vevo.py | 200 +- youtube_dl/extractor/vgtv.py | 21 +- youtube_dl/extractor/vice.py | 99 +- youtube_dl/extractor/viddler.py | 4 +- youtube_dl/extractor/videodetective.py | 9 +- youtube_dl/extractor/videomega.py | 10 +- youtube_dl/extractor/videomore.py | 1 + youtube_dl/extractor/videott.py | 2 +- youtube_dl/extractor/vidio.py | 73 + youtube_dl/extractor/vidzi.py | 27 +- youtube_dl/extractor/vier.py | 1 + .../extractor/{snagfilms.py => viewlift.py} | 39 +- youtube_dl/extractor/viewster.py | 124 +- youtube_dl/extractor/viidea.py | 3 +- youtube_dl/extractor/viki.py | 28 +- youtube_dl/extractor/vimeo.py | 377 ++- youtube_dl/extractor/vine.py | 5 + youtube_dl/extractor/vk.py | 109 +- youtube_dl/extractor/vlive.py | 87 +- youtube_dl/extractor/vodlocker.py | 4 +- youtube_dl/extractor/voicerepublic.py | 11 +- youtube_dl/extractor/voxmedia.py | 136 + youtube_dl/extractor/vporn.py | 10 +- youtube_dl/extractor/vrt.py | 34 +- youtube_dl/extractor/vube.py | 2 +- youtube_dl/extractor/vuclip.py | 2 +- youtube_dl/extractor/vulture.py | 69 - youtube_dl/extractor/walla.py | 2 +- youtube_dl/extractor/washingtonpost.py | 144 +- youtube_dl/extractor/wat.py | 137 +- .../{sexykarma.py => watchindianporn.py} | 63 +- youtube_dl/extractor/wayofthemaster.py | 52 - youtube_dl/extractor/wdr.py | 403 ++- youtube_dl/extractor/webofstories.py | 64 +- youtube_dl/extractor/weibo.py | 49 - youtube_dl/extractor/weiqitv.py | 2 +- youtube_dl/extractor/wimp.py | 37 +- youtube_dl/extractor/wistia.py | 89 +- youtube_dl/extractor/wrzuta.py | 94 +- youtube_dl/extractor/wsj.py | 95 +- youtube_dl/extractor/xbef.py | 2 +- youtube_dl/extractor/xboxclips.py | 2 +- youtube_dl/extractor/xfileshare.py | 102 +- youtube_dl/extractor/xhamster.py | 82 +- youtube_dl/extractor/xiami.py | 168 ++ youtube_dl/extractor/xminus.py | 45 +- youtube_dl/extractor/xnxx.py | 22 +- youtube_dl/extractor/xuite.py | 1 + youtube_dl/extractor/xvideos.py | 43 +- youtube_dl/extractor/yahoo.py | 88 +- youtube_dl/extractor/yam.py | 2 +- youtube_dl/extractor/yandexmusic.py | 167 +- youtube_dl/extractor/ynet.py | 6 +- youtube_dl/extractor/youku.py | 72 +- youtube_dl/extractor/youporn.py | 17 +- youtube_dl/extractor/youtube.py | 385 ++- youtube_dl/extractor/zdf.py | 12 + youtube_dl/jsinterp.py | 2 +- youtube_dl/options.py | 33 +- youtube_dl/postprocessor/__init__.py | 2 + youtube_dl/postprocessor/execafterdownload.py | 4 +- youtube_dl/postprocessor/ffmpeg.py | 103 +- youtube_dl/postprocessor/xattrpp.py | 5 +- youtube_dl/socks.py | 271 ++ youtube_dl/swfinterp.py | 18 +- youtube_dl/update.py | 9 +- youtube_dl/utils.py | 523 +++- youtube_dl/version.py | 2 +- 499 files changed, 21202 insertions(+), 11495 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE_tmpl.md create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 AUTHORS create mode 100644 CONTRIBUTING.md delete mode 100644 README.txt create mode 100644 devscripts/create-github-release.py create mode 100755 devscripts/install_srelay.sh create mode 100644 devscripts/lazy_load_template.py create mode 100644 devscripts/make_issue_template.py create mode 100644 devscripts/make_lazy_extractors.py create mode 100644 setup.cfg delete mode 100644 test/swftests/ArrayAccess.swf delete mode 100644 test/swftests/ClassCall.swf delete mode 100644 test/swftests/ClassConstruction.swf delete mode 100644 test/swftests/ConstArrayAccess.swf delete mode 100644 test/swftests/ConstantInt.swf delete mode 100644 test/swftests/DictCall.swf delete mode 100644 test/swftests/EqualsOperator.swf delete mode 100644 test/swftests/LocalVars.swf delete mode 100644 test/swftests/MemberAssignment.swf delete mode 100644 test/swftests/NeOperator.swf delete mode 100644 test/swftests/PrivateCall.swf delete mode 100644 test/swftests/PrivateVoidCall.swf delete mode 100644 test/swftests/StaticAssignment.swf delete mode 100644 test/swftests/StaticConstArrayAccess.swf delete mode 100644 test/swftests/StaticRetrieval.swf delete mode 100644 test/swftests/StringBasics.swf delete mode 100644 test/swftests/StringCharCodeAt.swf delete mode 100644 test/swftests/StringConversion.swf delete mode 100644 test/swftests/StringFunctions.swf create mode 100644 test/test_socks.py delete mode 100644 test/video-vid.mp4 create mode 100644 tox.ini delete mode 100755 youtube-dl delete mode 100644 youtube-dl.1 delete mode 100644 youtube-dl.bash-completion delete mode 100644 youtube-dl.fish create mode 100644 youtube-dl.plugin.zsh delete mode 100644 youtube-dl.zsh create mode 100644 youtube_dl/extractor/abcnews.py create mode 100644 youtube_dl/extractor/afreecatv.py create mode 100644 youtube_dl/extractor/anvato.py create mode 100644 youtube_dl/extractor/audioboom.py create mode 100644 youtube_dl/extractor/biobiochiletv.py create mode 100644 youtube_dl/extractor/biqle.py create mode 100644 youtube_dl/extractor/bokecc.py create mode 100644 youtube_dl/extractor/bravotv.py create mode 100644 youtube_dl/extractor/camwithher.py create mode 100644 youtube_dl/extractor/carambatv.py rename youtube_dl/extractor/{cnet.py => cbsinteractive.py} (59%) create mode 100644 youtube_dl/extractor/cbslocal.py create mode 100755 youtube_dl/extractor/cda.py delete mode 100644 youtube_dl/extractor/cinemassacre.py create mode 100644 youtube_dl/extractor/cliprs.py create mode 100644 youtube_dl/extractor/closertotruth.py create mode 100644 youtube_dl/extractor/cnbc.py delete mode 100644 youtube_dl/extractor/collegehumor.py create mode 100644 youtube_dl/extractor/commonprotocols.py create mode 100644 youtube_dl/extractor/coub.py create mode 100644 youtube_dl/extractor/dailymail.py create mode 100644 youtube_dl/extractor/dispeak.py delete mode 100644 youtube_dl/extractor/dump.py create mode 100644 youtube_dl/extractor/dw.py create mode 100644 youtube_dl/extractor/extractors.py create mode 100644 youtube_dl/extractor/eyedotv.py create mode 100644 youtube_dl/extractor/formula1.py delete mode 100644 youtube_dl/extractor/gametrailers.py create mode 100644 youtube_dl/extractor/godtv.py create mode 100644 youtube_dl/extractor/hbo.py delete mode 100644 youtube_dl/extractor/jadorecettepub.py create mode 100644 youtube_dl/extractor/kusi.py create mode 100644 youtube_dl/extractor/learnr.py rename youtube_dl/extractor/{letv.py => leeco.py} (81%) create mode 100644 youtube_dl/extractor/libraryofcongress.py create mode 100644 youtube_dl/extractor/litv.py create mode 100644 youtube_dl/extractor/localnews8.py create mode 100644 youtube_dl/extractor/makerschannel.py delete mode 100644 youtube_dl/extractor/malemotion.py create mode 100644 youtube_dl/extractor/mgtv.py create mode 100644 youtube_dl/extractor/microsoftvirtualacademy.py create mode 100644 youtube_dl/extractor/minoto.py create mode 100644 youtube_dl/extractor/mnet.py delete mode 100644 youtube_dl/extractor/mooshare.py delete mode 100644 youtube_dl/extractor/muzu.py delete mode 100644 youtube_dl/extractor/nerdist.py create mode 100644 youtube_dl/extractor/once.py create mode 100644 youtube_dl/extractor/openload.py create mode 100644 youtube_dl/extractor/people.py delete mode 100644 youtube_dl/extractor/planetaplay.py create mode 100644 youtube_dl/extractor/presstv.py delete mode 100644 youtube_dl/extractor/quickvid.py create mode 100644 youtube_dl/extractor/radiocanada.py create mode 100644 youtube_dl/extractor/reuters.py create mode 100644 youtube_dl/extractor/rice.py create mode 100644 youtube_dl/extractor/rockstargames.py create mode 100644 youtube_dl/extractor/seeker.py create mode 100644 youtube_dl/extractor/sendtonews.py delete mode 100644 youtube_dl/extractor/space.py create mode 100644 youtube_dl/extractor/sportschau.py create mode 100644 youtube_dl/extractor/tdslifeway.py create mode 100644 youtube_dl/extractor/telewebion.py delete mode 100644 youtube_dl/extractor/tenplay.py delete mode 100644 youtube_dl/extractor/theonion.py create mode 100644 youtube_dl/extractor/thescene.py create mode 100644 youtube_dl/extractor/thestar.py create mode 100644 youtube_dl/extractor/threeqsdn.py create mode 100644 youtube_dl/extractor/tv3.py delete mode 100644 youtube_dl/extractor/ubu.py create mode 100644 youtube_dl/extractor/usatoday.py create mode 100644 youtube_dl/extractor/ustudio.py create mode 100644 youtube_dl/extractor/vidio.py rename youtube_dl/extractor/{snagfilms.py => viewlift.py} (80%) create mode 100644 youtube_dl/extractor/voxmedia.py delete mode 100644 youtube_dl/extractor/vulture.py rename youtube_dl/extractor/{sexykarma.py => watchindianporn.py} (54%) delete mode 100644 youtube_dl/extractor/wayofthemaster.py delete mode 100644 youtube_dl/extractor/weibo.py create mode 100644 youtube_dl/extractor/xiami.py create mode 100644 youtube_dl/socks.py diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..c73f9a9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,58 @@ +## Please follow the guide below + +- You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly +- Put an `x` into all the boxes [ ] relevant to your *issue* (like that [x]) +- Use *Preview* tab to see how your issue will actually look like + +--- + +### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2016.06.25*. If it's not read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected. +- [ ] I've **verified** and **I assure** that I'm running youtube-dl **2016.06.25** + +### Before submitting an *issue* make sure you have: +- [ ] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections +- [ ] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones + +### What is the purpose of your *issue*? +- [ ] Bug report (encountered problems with youtube-dl) +- [ ] Site support request (request for adding support for a new site) +- [ ] Feature request (request for a new functionality) +- [ ] Question +- [ ] Other + +--- + +### The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your *issue* + +--- + +### If the purpose of this *issue* is a *bug report*, *site support request* or you are not completely sure provide the full verbose output as follows: + +Add `-v` flag to **your command line** you run youtube-dl with, copy the **whole** output and insert it here. It should look similar to one below (replace it with **your** log inserted between triple ```): +``` +$ youtube-dl -v +[debug] System config: [] +[debug] User config: [] +[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj'] +[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251 +[debug] youtube-dl version 2016.06.25 +[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2 +[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4 +[debug] Proxy map: {} +... + +``` + +--- + +### If the purpose of this *issue* is a *site support request* please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**): +- Single video: https://www.youtube.com/watch?v=BaW_jenozKc +- Single video: https://youtu.be/BaW_jenozKc +- Playlist: https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc + +--- + +### Description of your *issue*, suggested solution and other information + +Explanation of your *issue* in arbitrary form goes here. Please make sure the [description is worded well enough to be understood](https://github.com/rg3/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide as much context and examples as possible. +If work on your *issue* required an account credentials please provide them or explain how one can obtain them. diff --git a/.github/ISSUE_TEMPLATE_tmpl.md b/.github/ISSUE_TEMPLATE_tmpl.md new file mode 100644 index 0000000..a5e6a42 --- /dev/null +++ b/.github/ISSUE_TEMPLATE_tmpl.md @@ -0,0 +1,58 @@ +## Please follow the guide below + +- You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly +- Put an `x` into all the boxes [ ] relevant to your *issue* (like that [x]) +- Use *Preview* tab to see how your issue will actually look like + +--- + +### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *%(version)s*. If it's not read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected. +- [ ] I've **verified** and **I assure** that I'm running youtube-dl **%(version)s** + +### Before submitting an *issue* make sure you have: +- [ ] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections +- [ ] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones + +### What is the purpose of your *issue*? +- [ ] Bug report (encountered problems with youtube-dl) +- [ ] Site support request (request for adding support for a new site) +- [ ] Feature request (request for a new functionality) +- [ ] Question +- [ ] Other + +--- + +### The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your *issue* + +--- + +### If the purpose of this *issue* is a *bug report*, *site support request* or you are not completely sure provide the full verbose output as follows: + +Add `-v` flag to **your command line** you run youtube-dl with, copy the **whole** output and insert it here. It should look similar to one below (replace it with **your** log inserted between triple ```): +``` +$ youtube-dl -v +[debug] System config: [] +[debug] User config: [] +[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj'] +[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251 +[debug] youtube-dl version %(version)s +[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2 +[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4 +[debug] Proxy map: {} +... + +``` + +--- + +### If the purpose of this *issue* is a *site support request* please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**): +- Single video: https://www.youtube.com/watch?v=BaW_jenozKc +- Single video: https://youtu.be/BaW_jenozKc +- Playlist: https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc + +--- + +### Description of your *issue*, suggested solution and other information + +Explanation of your *issue* in arbitrary form goes here. Please make sure the [description is worded well enough to be understood](https://github.com/rg3/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide as much context and examples as possible. +If work on your *issue* required an account credentials please provide them or explain how one can obtain them. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a802c75 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +*.pyc +*.pyo +*.class +*~ +*.DS_Store +wine-py2exe/ +py2exe.log +*.kate-swp +build/ +dist/ +MANIFEST +README.txt +youtube-dl.1 +youtube-dl.bash-completion +youtube-dl.fish +youtube_dl/extractor/lazy_extractors.py +youtube-dl +youtube-dl.exe +youtube-dl.tar.gz +.coverage +cover/ +updates_key.pem +*.egg-info +*.srt +*.sbv +*.vtt +*.flv +*.mp4 +*.m4a +*.m4v +*.mp3 +*.part +*.swp +test/testdata +test/local_parameters.json +.tox +youtube-dl.zsh + +# IntelliJ related files +.idea +*.iml + +tmp/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..136c339 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" +sudo: false +install: + - bash ./devscripts/install_srelay.sh + - export PATH=$PATH:$(pwd)/tmp/srelay-0.4.8b6 +script: nosetests test --verbose +notifications: + email: + - filippo.valsorda@gmail.com + - yasoob.khld@gmail.com +# irc: +# channels: +# - "irc.freenode.org#youtube-dl" +# skip_join: true diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..cdf655c --- /dev/null +++ b/AUTHORS @@ -0,0 +1,177 @@ +Ricardo Garcia Gonzalez +Danny Colligan +Benjamin Johnson +Vasyl' Vavrychuk +Witold Baryluk +Paweł Paprota +Gergely Imreh +Rogério Brito +Philipp Hagemeister +Sören Schulze +Kevin Ngo +Ori Avtalion +shizeeg +Filippo Valsorda +Christian Albrecht +Dave Vasilevsky +Jaime Marquínez Ferrándiz +Jeff Crouse +Osama Khalid +Michael Walter +M. Yasoob Ullah Khalid +Julien Fraichard +Johny Mo Swag +Axel Noack +Albert Kim +Pierre Rudloff +Huarong Huo +Ismael Mejía +Steffan 'Ruirize' James +Andras Elso +Jelle van der Waa +Marcin Cieślak +Anton Larionov +Takuya Tsuchida +Sergey M. +Michael Orlitzky +Chris Gahan +Saimadhav Heblikar +Mike Col +Oleg Prutz +pulpe +Andreas Schmitz +Michael Kaiser +Niklas Laxström +David Triendl +Anthony Weems +David Wagner +Juan C. Olivares +Mattias Harrysson +phaer +Sainyam Kapoor +Nicolas Évrard +Jason Normore +Hoje Lee +Adam Thalhammer +Georg Jähnig +Ralf Haring +Koki Takahashi +Ariset Llerena +Adam Malcontenti-Wilson +Tobias Bell +Naglis Jonaitis +Charles Chen +Hassaan Ali +Dobrosław Żybort +David Fabijan +Sebastian Haas +Alexander Kirk +Erik Johnson +Keith Beckman +Ole Ernst +Aaron McDaniel (mcd1992) +Magnus Kolstad +Hari Padmanaban +Carlos Ramos +5moufl +lenaten +Dennis Scheiba +Damon Timm +winwon +Xavier Beynon +Gabriel Schubiner +xantares +Jan Matějka +Mauroy Sébastien +William Sewell +Dao Hoang Son +Oskar Jauch +Matthew Rayfield +t0mm0 +Tithen-Firion +Zack Fernandes +cryptonaut +Adrian Kretz +Mathias Rav +Petr Kutalek +Will Glynn +Max Reimann +Cédric Luthi +Thijs Vermeir +Joel Leclerc +Christopher Krooss +Ondřej Caletka +Dinesh S +Johan K. Jensen +Yen Chi Hsuan +Enam Mijbah Noor +David Luhmer +Shaya Goldberg +Paul Hartmann +Frans de Jonge +Robin de Rooij +Ryan Schmidt +Leslie P. Polzer +Duncan Keall +Alexander Mamay +Devin J. Pohly +Eduardo Ferro Aldama +Jeff Buchbinder +Amish Bhadeshia +Joram Schrijver +Will W. +Mohammad Teimori Pabandi +Roman Le Négrate +Matthias Küch +Julian Richen +Ping O. +Mister Hat +Peter Ding +jackyzy823 +George Brighton +Remita Amine +Aurélio A. Heckert +Bernhard Minks +sceext +Zach Bruggeman +Tjark Saul +slangangular +Behrouz Abbasi +ngld +nyuszika7h +Shaun Walbridge +Lee Jenkins +Anssi Hannula +Lukáš Lalinský +Qijiang Fan +Rémy Léone +Marco Ferragina +reiv +Muratcan Simsek +Evan Lu +flatgreen +Brian Foley +Vignesh Venkat +Tom Gijselinck +Founder Fang +Andrew Alexeyew +Saso Bezlaj +Erwin de Haan +Jens Wille +Robin Houtevelts +Patrick Griffis +Aidan Rowe +mutantmonkey +Ben Congdon +Kacper Michajłow +José Joaquín Atria +Viťas Strádal +Kagami Hiiragi +Philip Huppert +blahgeek +Kevin Deldycke +inondle +Tomáš Čech +Déstin Reed +Roman Tsiupa +Artur Krysiak diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a59fac9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,158 @@ +**Please include the full output of youtube-dl when run with `-v`**, i.e. **add** `-v` flag to **your command line**, copy the **whole** output and post it in the issue body wrapped in \`\`\` for better formatting. It should look similar to this: +``` +$ youtube-dl -v +[debug] System config: [] +[debug] User config: [] +[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj'] +[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251 +[debug] youtube-dl version 2015.12.06 +[debug] Git HEAD: 135392e +[debug] Python version 2.6.6 - Windows-2003Server-5.2.3790-SP2 +[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4 +[debug] Proxy map: {} +... +``` +**Do not post screenshots of verbose log only plain text is acceptable.** + +The output (including the first lines) contains important debugging information. Issues without the full output are often not reproducible and therefore do not get solved in short order, if ever. + +Please re-read your issue once again to avoid a couple of common mistakes (you can and should use this as a checklist): + +### Is the description of the issue itself sufficient? + +We often get issue reports that we cannot really decipher. While in most cases we eventually get the required information after asking back multiple times, this poses an unnecessary drain on our resources. Many contributors, including myself, are also not native speakers, so we may misread some parts. + +So please elaborate on what feature you are requesting, or what bug you want to be fixed. Make sure that it's obvious + +- What the problem is +- How it could be fixed +- How your proposed solution would look like + +If your report is shorter than two lines, it is almost certainly missing some of these, which makes it hard for us to respond to it. We're often too polite to close the issue outright, but the missing info makes misinterpretation likely. As a committer myself, I often get frustrated by these issues, since the only possible way for me to move forward on them is to ask for clarification over and over. + +For bug reports, this means that your report should contain the *complete* output of youtube-dl when called with the `-v` flag. The error message you get for (most) bugs even says so, but you would not believe how many of our bug reports do not contain this information. + +If your server has multiple IPs or you suspect censorship, adding `--call-home` may be a good idea to get more diagnostics. If the error is `ERROR: Unable to extract ...` and you cannot reproduce it from multiple countries, add `--dump-pages` (warning: this will yield a rather large output, redirect it to the file `log.txt` by adding `>log.txt 2>&1` to your command-line) or upload the `.dump` files you get when you add `--write-pages` [somewhere](https://gist.github.com/). + +**Site support requests must contain an example URL**. An example URL is a URL you might want to download, like `http://www.youtube.com/watch?v=BaW_jenozKc`. There should be an obvious video present. Except under very special circumstances, the main page of a video service (e.g. `http://www.youtube.com/`) is *not* an example URL. + +### Are you using the latest version? + +Before reporting any issue, type `youtube-dl -U`. This should report that you're up-to-date. About 20% of the reports we receive are already fixed, but people are using outdated versions. This goes for feature requests as well. + +### Is the issue already documented? + +Make sure that someone has not already opened the issue you're trying to open. Search at the top of the window or browse the [GitHub Issues](https://github.com/rg3/youtube-dl/search?type=Issues) of this repository. If there is an issue, feel free to write something along the lines of "This affects me as well, with version 2015.01.01. Here is some more information on the issue: ...". While some issues may be old, a new post into them often spurs rapid activity. + +### Why are existing options not enough? + +Before requesting a new feature, please have a quick peek at [the list of supported options](https://github.com/rg3/youtube-dl/blob/master/README.md#synopsis). Many feature requests are for features that actually exist already! Please, absolutely do show off your work in the issue report and detail how the existing similar options do *not* solve your problem. + +### Is there enough context in your bug report? + +People want to solve problems, and often think they do us a favor by breaking down their larger problems (e.g. wanting to skip already downloaded files) to a specific request (e.g. requesting us to look whether the file exists before downloading the info page). However, what often happens is that they break down the problem into two steps: One simple, and one impossible (or extremely complicated one). + +We are then presented with a very complicated request when the original problem could be solved far easier, e.g. by recording the downloaded video IDs in a separate file. To avoid this, you must include the greater context where it is non-obvious. In particular, every feature request that does not consist of adding support for a new site should contain a use case scenario that explains in what situation the missing feature would be useful. + +### Does the issue involve one problem, and one problem only? + +Some of our users seem to think there is a limit of issues they can or should open. There is no limit of issues they can or should open. While it may seem appealing to be able to dump all your issues into one ticket, that means that someone who solves one of your issues cannot mark the issue as closed. Typically, reporting a bunch of issues leads to the ticket lingering since nobody wants to attack that behemoth, until someone mercifully splits the issue into multiple ones. + +In particular, every site support request issue should only pertain to services at one site (generally under a common domain, but always using the same backend technology). Do not request support for vimeo user videos, Whitehouse podcasts, and Google Plus pages in the same issue. Also, make sure that you don't post bug reports alongside feature requests. As a rule of thumb, a feature request does not include outputs of youtube-dl that are not immediately related to the feature at hand. Do not post reports of a network error alongside the request for a new video service. + +### Is anyone going to need the feature? + +Only post features that you (or an incapacitated friend you can personally talk to) require. Do not post features because they seem like a good idea. If they are really useful, they will be requested by someone who requires them. + +### Is your question about youtube-dl? + +It may sound strange, but some bug reports we receive are completely unrelated to youtube-dl and relate to a different or even the reporter's own application. Please make sure that you are actually using youtube-dl. If you are using a UI for youtube-dl, report the bug to the maintainer of the actual application providing the UI. On the other hand, if your UI for youtube-dl fails in some way you believe is related to youtube-dl, by all means, go ahead and report the bug. + +# DEVELOPER INSTRUCTIONS + +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. + +To run youtube-dl as a developer, you don't need to build anything either. Simply execute + + python -m youtube_dl + +To run the test, simply invoke your favorite test runner, or execute a test file directly; any of the following work: + + python -m unittest discover + python test/test_download.py + nosetests + +If you want to create a build of youtube-dl yourself, you'll need + +* python +* make (both GNU make and BSD make are supported) +* pandoc +* zip +* nosetests + +### Adding support for a new site + +If you want to add support for a new site, first of all **make sure** this site is **not dedicated to [copyright infringement](#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free)**. youtube-dl does **not support** such sites thus pull requests adding support for them **will be rejected**. + +After you have ensured this site is distributing it's content legally, you can follow this quick list (assuming your service is called `yourextractor`): + +1. [Fork this repository](https://github.com/rg3/youtube-dl/fork) +2. Check out the source code with `git clone git@github.com:YOUR_GITHUB_USERNAME/youtube-dl.git` +3. Start a new git branch with `cd youtube-dl; git checkout -b yourextractor` +4. Start with this simple template and save it to `youtube_dl/extractor/yourextractor.py`: + ```python + # coding: utf-8 + from __future__ import unicode_literals + + from .common import InfoExtractor + + + class YourExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?yourextractor\.com/watch/(?P[0-9]+)' + _TEST = { + 'url': 'http://yourextractor.com/watch/42', + 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', + 'info_dict': { + 'id': '42', + 'ext': 'mp4', + 'title': 'Video title goes here', + 'thumbnail': 're:^https?://.*\.jpg$', + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + # TODO more code goes here, for example ... + title = self._html_search_regex(r'

(.+?)

', webpage, 'title') + + return { + 'id': video_id, + 'title': title, + 'description': self._og_search_description(webpage), + 'uploader': self._search_regex(r']+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), + # TODO more properties (see youtube_dl/extractor/common.py) + } + ``` +5. Add an import in [`youtube_dl/extractor/extractors.py`](https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/extractors.py). +6. Run `python test/test_download.py TestDownload.test_YourExtractor`. This *should fail* at first, but you can continually re-run it until you're done. If you decide to add more than one test, then rename ``_TEST`` to ``_TESTS`` and make it into a list of dictionaries. The tests will then be named `TestDownload.test_YourExtractor`, `TestDownload.test_YourExtractor_1`, `TestDownload.test_YourExtractor_2`, etc. +7. Have a look at [`youtube_dl/extractor/common.py`](https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py) for possible helper methods and a [detailed description of what your extractor should and may return](https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py#L74-L252). Add tests and code for as many as you want. +8. Keep in mind that the only mandatory fields in info dict for successful extraction process are `id`, `title` and either `url` or `formats`, i.e. these are the critical data the extraction does not make any sense without. This means that [any field](https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py#L148-L252) apart from aforementioned mandatory ones should be treated **as optional** and extraction should be **tolerate** to situations when sources for these fields can potentially be unavailable (even if they always available at the moment) and **future-proof** in order not to break the extraction of general purpose mandatory fields. For example, if you have some intermediate dict `meta` that is a source of metadata and it has a key `summary` that you want to extract and put into resulting info dict as `description`, you should be ready that this key may be missing from the `meta` dict, i.e. you should extract it as `meta.get('summary')` and not `meta['summary']`. Similarly, you should pass `fatal=False` when extracting data from a webpage with `_search_regex/_html_search_regex`. +9. Check the code with [flake8](https://pypi.python.org/pypi/flake8). Also make sure your code works under all [Python](http://www.python.org/) versions claimed supported by youtube-dl, namely 2.6, 2.7, and 3.2+. +10. When the tests pass, [add](http://git-scm.com/docs/git-add) the new files and [commit](http://git-scm.com/docs/git-commit) them and [push](http://git-scm.com/docs/git-push) the result, like this: + + $ git add youtube_dl/extractor/extractors.py + $ git add youtube_dl/extractor/yourextractor.py + $ git commit -m '[yourextractor] Add new extractor' + $ git push origin yourextractor + +11. Finally, [create a pull request](https://help.github.com/articles/creating-a-pull-request). We'll then review and merge it. + +In any case, thank you very much for your contributions! + diff --git a/Makefile b/Makefile index cb449b7..6ee4ba4 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ all: youtube-dl README.md CONTRIBUTING.md README.txt youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish supportedsites clean: - 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 *.mp4 *.flv *.mp3 *.avi CONTRIBUTING.md.tmp youtube-dl youtube-dl.exe + 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 youtube_dl/extractor/lazy_extractors.py *.dump *.part *.info.json *.mp4 *.m4a *.flv *.mp3 *.avi *.mkv *.webm *.jpg *.png CONTRIBUTING.md.tmp ISSUE_TEMPLATE.md.tmp youtube-dl youtube-dl.exe find . -name "*.pyc" -delete + find . -name "*.class" -delete PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin @@ -11,15 +12,7 @@ SHAREDIR ?= $(PREFIX)/share PYTHON ?= /usr/bin/env python # set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local -ifeq ($(PREFIX),/usr) - SYSCONFDIR=/etc -else - ifeq ($(PREFIX),/usr/local) - SYSCONFDIR=/etc - else - SYSCONFDIR=$(PREFIX)/etc - endif -endif +SYSCONFDIR != if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi install: youtube-dl youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish install -d $(DESTDIR)$(BINDIR) @@ -44,7 +37,7 @@ test: ot: offlinetest offlinetest: codetest - nosetests --verbose test --exclude test_download.py --exclude test_age_restriction.py --exclude test_subtitles.py --exclude test_write_annotations.py --exclude test_youtube_lists.py --exclude test_iqiyi_sdk_interpreter.py + $(PYTHON) -m nose --verbose test --exclude test_download.py --exclude test_age_restriction.py --exclude test_subtitles.py --exclude test_write_annotations.py --exclude test_youtube_lists.py --exclude test_iqiyi_sdk_interpreter.py --exclude test_socks.py tar: youtube-dl.tar.gz @@ -66,6 +59,9 @@ README.md: youtube_dl/*.py youtube_dl/*/*.py CONTRIBUTING.md: README.md $(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md +.github/ISSUE_TEMPLATE.md: devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl.md youtube_dl/version.py + $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl.md .github/ISSUE_TEMPLATE.md + supportedsites: $(PYTHON) devscripts/make_supportedsites.py docs/supportedsites.md @@ -73,7 +69,7 @@ README.txt: README.md pandoc -f markdown -t plain README.md -o README.txt youtube-dl.1: README.md - $(PYTHON) devscripts/prepare_manpage.py >youtube-dl.1.temp.md + $(PYTHON) devscripts/prepare_manpage.py youtube-dl.1.temp.md pandoc -s -f markdown -t man youtube-dl.1.temp.md -o youtube-dl.1 rm -f youtube-dl.1.temp.md @@ -92,6 +88,12 @@ youtube-dl.fish: youtube_dl/*.py youtube_dl/*/*.py devscripts/fish-completion.in fish-completion: youtube-dl.fish +lazy-extractors: youtube_dl/extractor/lazy_extractors.py + +_EXTRACTOR_FILES != find youtube_dl/extractor -iname '*.py' -and -not -iname 'lazy_extractors.py' +youtube_dl/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES) + $(PYTHON) devscripts/make_lazy_extractors.py $@ + youtube-dl.tar.gz: youtube-dl README.md README.txt youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish @tar -czf youtube-dl.tar.gz --transform "s|^|youtube-dl/|" --owner 0 --group 0 \ --exclude '*.DS_Store' \ diff --git a/README.md b/README.md index db49ab6..c6feef1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ youtube-dl - download videos from youtube.com or other video platforms To install it right away for all UNIX users (Linux, OS X, etc.), type: - sudo curl https://yt-dl.org/latest/youtube-dl -o /usr/local/bin/youtube-dl + sudo curl -L https://yt-dl.org/latest/youtube-dl -o /usr/local/bin/youtube-dl sudo chmod a+rx /usr/local/bin/youtube-dl If you do not have curl, you can alternatively use a recent wget: @@ -25,20 +25,26 @@ If you do not have curl, you can alternatively use a recent wget: sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl sudo chmod a+rx /usr/local/bin/youtube-dl -Windows users can [download a .exe file](https://yt-dl.org/latest/youtube-dl.exe) and place it in their home directory or any other location on their [PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29). +Windows users can [download an .exe file](https://yt-dl.org/latest/youtube-dl.exe) and place it in any location on their [PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29) except for `%SYSTEMROOT%\System32` (e.g. **do not** put in `C:\Windows\System32`). -OS X users can install **youtube-dl** with [Homebrew](http://brew.sh/). +You can also use pip: + + sudo pip install --upgrade youtube-dl + +This command will update youtube-dl if you have already installed it. See the [pypi page](https://pypi.python.org/pypi/youtube_dl) for more information. + +OS X users can install youtube-dl with [Homebrew](http://brew.sh/): brew install youtube-dl -You can also use pip: +Or with [MacPorts](https://www.macports.org/): - sudo pip install youtube-dl + sudo port install youtube-dl Alternatively, refer to the [developer instructions](#developer-instructions) for how to check out and work with the git repository. For further options, including PGP signatures, see the [youtube-dl Download Page](https://rg3.github.io/youtube-dl/download.html). # DESCRIPTION -**youtube-dl** is a small command-line program to download videos from +**youtube-dl** is a command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is not platform specific. It should work on your Unix box, on Windows or on Mac OS X. It is released to the public domain, @@ -73,19 +79,23 @@ which means you can modify it, redistribute it or use it however you like. repairs broken URLs, but emits an error if this is not possible instead of searching. --ignore-config Do not read configuration files. When given - in the global configuration file /etc - /youtube-dl.conf: Do not read the user + in the global configuration file + /etc/youtube-dl.conf: Do not read the user configuration in ~/.config/youtube- dl/config (%APPDATA%/youtube-dl/config.txt on Windows) --flat-playlist Do not extract the videos of a playlist, only list them. + --mark-watched Mark videos watched (YouTube only) + --no-mark-watched Do not mark videos watched (YouTube only) --no-color Do not emit color codes in output ## Network Options: - --proxy URL Use the specified HTTP/HTTPS proxy. Pass in - an empty string (--proxy "") for direct - connection + --proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. + To enable experimental SOCKS proxy, specify + a proper scheme. For example + socks5://127.0.0.1:1080/. Pass in an empty + string (--proxy "") for direct connection --socket-timeout SECONDS Time to wait before giving up, in seconds --source-address IP Client-side IP address to bind to (experimental) @@ -158,10 +168,12 @@ which means you can modify it, redistribute it or use it however you like. (experimental) ## Download Options: - -r, --rate-limit LIMIT Maximum download rate in bytes per second + -r, --limit-rate RATE Maximum download rate in bytes per second (e.g. 50K or 4.2M) -R, --retries RETRIES Number of retries (default is 10), or "infinite". + --fragment-retries RETRIES Number of retries for a fragment (default + is 10), or "infinite" (DASH only) --buffer-size SIZE Size of download buffer (e.g. 1024 or 16K) (default is 1024) --no-resize-buffer Do not automatically adjust the buffer @@ -172,14 +184,16 @@ which means you can modify it, redistribute it or use it however you like. --xattr-set-filesize Set file xattribute ytdl.filesize with expected filesize (experimental) --hls-prefer-native Use the native HLS downloader instead of - ffmpeg (experimental) + ffmpeg + --hls-prefer-ffmpeg Use ffmpeg instead of the native HLS + downloader --hls-use-mpegts Use the mpegts container for HLS videos, allowing to play the video while downloading (some players may not be able to play it) --external-downloader COMMAND Use the specified external downloader. Currently supports - aria2c,axel,curl,httpie,wget + aria2c,avconv,axel,curl,ffmpeg,httpie,wget --external-downloader-args ARGS Give these arguments to the external downloader @@ -241,18 +255,19 @@ which means you can modify it, redistribute it or use it however you like. --write-info-json Write video metadata to a .info.json file --write-annotations Write video annotations to a .annotations.xml file - --load-info FILE JSON file containing the video information + --load-info-json FILE JSON file containing the video information (created with the "--write-info-json" option) --cookies FILE File to read cookies from and dump cookie jar in --cache-dir DIR Location in the filesystem where youtube-dl can store some downloaded information - permanently. By default $XDG_CACHE_HOME - /youtube-dl or ~/.cache/youtube-dl . At the - moment, only YouTube player files (for - videos with obfuscated signatures) are - cached, but that may change. + permanently. By default + $XDG_CACHE_HOME/youtube-dl or + ~/.cache/youtube-dl . At the moment, only + YouTube player files (for videos with + obfuscated signatures) are cached, but that + may change. --no-cache-dir Disable filesystem caching --rm-cache-dir Delete all filesystem cache files @@ -374,8 +389,8 @@ which means you can modify it, redistribute it or use it however you like. --no-post-overwrites Do not overwrite post-processed files; the post-processed files are overwritten by default - --embed-subs Embed subtitles in the video (only for mkv - and mp4 videos) + --embed-subs Embed subtitles in the video (only for mp4, + webm and mkv videos) --embed-thumbnail Embed thumbnail in the audio as cover art --add-metadata Write metadata to the video file --metadata-from-title FORMAT Parse additional metadata like song title / @@ -409,18 +424,23 @@ which means you can modify it, redistribute it or use it however you like. # CONFIGURATION -You can configure youtube-dl by placing any supported command line option to a configuration file. On Linux, the system wide configuration file is located at `/etc/youtube-dl.conf` and the user wide configuration file at `~/.config/youtube-dl/config`. On Windows, the user wide configuration file locations are `%APPDATA%\youtube-dl\config.txt` or `C:\Users\\youtube-dl.conf`. For example, with the following configuration file youtube-dl will always extract the audio, not copy the mtime and use a proxy: +You can configure youtube-dl by placing any supported command line option to a configuration file. On Linux and OS X, the system wide configuration file is located at `/etc/youtube-dl.conf` and the user wide configuration file at `~/.config/youtube-dl/config`. On Windows, the user wide configuration file locations are `%APPDATA%\youtube-dl\config.txt` or `C:\Users\\youtube-dl.conf`. + +For example, with the following configuration file youtube-dl will always extract the audio, not copy the mtime, use a proxy and save all videos under `Movies` directory in your home directory: ``` ---extract-audio +-x --no-mtime --proxy 127.0.0.1:3128 +-o ~/Movies/%(title)s.%(ext)s ``` +Note that options in configuration file are just the same options aka switches used in regular command line calls thus there **must be no whitespace** after `-` or `--`, e.g. `-o` or `--proxy` but not `- o` or `-- proxy`. + You can use `--ignore-config` if you want to disable the configuration file for a particular youtube-dl run. ### Authentication with `.netrc` file -You may also want to configure automatic credentials storage for extractors that support authentication (by providing login and password with `--username` and `--password`) in order not to pass credentials as command line arguments on every youtube-dl execution and prevent tracking plain text passwords in the shell command history. You can achieve this using a [`.netrc` file](http://stackoverflow.com/tags/.netrc/info) on per extractor basis. For that you will need to create a`.netrc` file in your `$HOME` and restrict permissions to read/write by you only: +You may also want to configure automatic credentials storage for extractors that support authentication (by providing login and password with `--username` and `--password`) in order not to pass credentials as command line arguments on every youtube-dl execution and prevent tracking plain text passwords in the shell command history. You can achieve this using a [`.netrc` file](http://stackoverflow.com/tags/.netrc/info) on per extractor basis. For that you will need to create a `.netrc` file in your `$HOME` and restrict permissions to read/write by you only: ``` touch $HOME/.netrc chmod a-rwx,u+rw $HOME/.netrc @@ -440,7 +460,11 @@ On Windows you may also need to setup the `%HOME%` environment variable manually # OUTPUT TEMPLATE -The `-o` option allows users to indicate a template for the output file names. The basic usage is not to set any template arguments when downloading a single file, like in `youtube-dl -o funny_video.flv "http://some/video"`. However, it may contain special sequences that will be replaced when downloading each video. The special sequences have the format `%(NAME)s`. To clarify, that is a percent symbol followed by a name in parentheses, followed by a lowercase S. Allowed names are: +The `-o` option allows users to indicate a template for the output file names. + +**tl;dr:** [navigate me to examples](#output-template-examples). + +The basic usage is not to set any template arguments when downloading a single file, like in `youtube-dl -o funny_video.flv "http://some/video"`. However, it may contain special sequences that will be replaced when downloading each video. The special sequences have the format `%(NAME)s`. To clarify, that is a percent symbol followed by a name in parentheses, followed by a lowercase S. Allowed names are: - `id`: Video identifier - `title`: Video title @@ -449,7 +473,8 @@ The `-o` option allows users to indicate a template for the output file names. T - `alt_title`: A secondary title of the video - `display_id`: An alternative identifier for the video - `uploader`: Full name of the video uploader - - `creator`: The main artist who created the video + - `license`: License name the video is licensed under + - `creator`: The creator of the video - `release_date`: The date (YYYYMMDD) when the video was released - `timestamp`: UNIX timestamp of the moment the video became available - `upload_date`: Video upload date (YYYYMMDD) @@ -486,6 +511,9 @@ The `-o` option allows users to indicate a template for the output file names. T - `autonumber`: Five-digit number that will be increased with each download, starting at zero - `playlist`: Name or id of the playlist that contains the video - `playlist_index`: Index of the video in the playlist padded with leading zeros according to the total length of the playlist + - `playlist_id`: Playlist identifier + - `playlist_title`: Playlist title + Available for the video that belongs to some logical chapter or section: - `chapter`: Name or title of the chapter the video belongs to @@ -501,6 +529,18 @@ Available for the video that is an episode of some series or programme: - `episode_number`: Number of the video episode within a season - `episode_id`: Id of the video episode +Available for the media that is a track or a part of a music album: + - `track`: Title of the track + - `track_number`: Number of the track within an album or a disc + - `track_id`: Id of the track + - `artist`: Artist(s) of the track + - `genre`: Genre(s) of the track + - `album`: Title of the album the track belongs to + - `album_type`: Type of the album + - `album_artist`: List of all artists appeared on the album + - `disc_number`: Number of the disc or other physical medium the track belongs to + - `release_year`: Year (YYYY) when the album was released + Each aforementioned sequence when referenced in output template will be replaced by the actual value corresponding to the sequence name. Note that some of the sequences are not guaranteed to be present since they depend on the metadata obtained by particular extractor, such sequences will be replaced with `NA`. For example for `-o %(title)s-%(id)s.%(ext)s` and mp4 video with title `youtube-dl test video` and id `BaW_jenozKcj` this will result in a `youtube-dl test video-BaW_jenozKcj.mp4` file created in the current directory. @@ -513,7 +553,13 @@ The current default template is `%(title)s-%(id)s.%(ext)s`. In some cases, you don't want special characters such as 中, spaces, or &, such as when transferring the downloaded filename to a Windows system or the filename through an 8bit-unsafe channel. In these cases, add the `--restrict-filenames` flag to get a shorter title: -Examples (note on Windows you may need to use double quotes instead of single): +#### Output template and Windows batch files + +If you are using output template inside a Windows batch file then you must escape plain percent characters (`%`) by doubling, so that `-o "%(title)s-%(id)s.%(ext)s"` should become `-o "%%(title)s-%%(id)s.%%(ext)s"`. However you should not touch `%`'s that are not plain characters, e.g. environment variables for expansion should stay intact: `-o "C:\%HOMEPATH%\Desktop\%%(title)s.%%(ext)s"`. + +#### Output template examples + +Note on Windows you may need to use double quotes instead of single. ```bash $ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc @@ -525,6 +571,9 @@ youtube-dl_test_video_.mp4 # A simple file name # Download YouTube playlist videos in separate directory indexed by video order in a playlist $ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re +# Download all playlists of YouTube channel/user keeping each playlist in separate directory: +$ youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists + # Download Udemy course keeping each chapter in separate directory under MyVideos directory in your home $ youtube-dl -u user -p password -o '~/MyVideos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/java-tutorial/ @@ -543,6 +592,8 @@ But sometimes you may want to download in a different format, for example when y The general syntax for format selection is `--format FORMAT` or shorter `-f FORMAT` where `FORMAT` is a *selector expression*, i.e. an expression that describes format or formats you would like to download. +**tl;dr:** [navigate me to examples](#format-selection-examples). + The simplest case is requesting a specific format, for example with `-f 22` you can download the format with format code equal to 22. You can get the list of available format codes for particular video using `--list-formats` or `-F`. Note that these format codes are extractor specific. You can also use a file extension (currently `3gp`, `aac`, `flv`, `m4a`, `mp3`, `mp4`, `ogg`, `wav`, `webm` are supported) to download best quality format of particular file extension served as a single file, e.g. `-f webm` will download best quality format with `webm` extension served as a single file. @@ -579,6 +630,7 @@ Also filtering work for comparisons `=` (equals), `!=` (not equals), `^=` (begin - `vcodec`: Name of the video codec in use - `container`: Name of the container format - `protocol`: The protocol that will be used for the actual download, lower-case. `http`, `https`, `rtsp`, `rtmp`, `rtmpe`, `m3u8`, or `m3u8_native` + - `format_id`: A short description of the format Note that none of the aforementioned meta fields are guaranteed to be present since this solely depends on the metadata obtained by particular extractor, i.e. the metadata offered by video hoster. @@ -588,11 +640,14 @@ You can merge the video and audio of two formats into a single file using `-f NUMBER (like "comment_count > - 12", also works with >=, <, <=, !=, =) to - compare against a number, and & to require - multiple matches. Values which are not - known are excluded unless you put a - question mark (?) after the operator.For - example, to only match videos that have - been liked more than 100 times and disliked - less than 50 times (or the dislike - functionality is not available at the given - service), but who also have a description, - use --match-filter "like_count > 100 & - dislike_count \youtube-dl.conf. For example, with the following -configuration file youtube-dl will always extract the audio, not copy -the mtime and use a proxy: - - --extract-audio - --no-mtime - --proxy 127.0.0.1:3128 - -You can use --ignore-config if you want to disable the configuration -file for a particular youtube-dl run. - -Authentication with .netrc file - -You may also want to configure automatic credentials storage for -extractors that support authentication (by providing login and password -with --username and --password) in order not to pass credentials as -command line arguments on every youtube-dl execution and prevent -tracking plain text passwords in the shell command history. You can -achieve this using a .netrc file on per extractor basis. For that you -will need to create a.netrc file in your $HOME and restrict permissions -to read/write by you only: - - touch $HOME/.netrc - chmod a-rwx,u+rw $HOME/.netrc - -After that you can add credentials for extractor in the following -format, where _extractor_ is the name of extractor in lowercase: - - machine login password - -For example: - - machine youtube login myaccount@gmail.com password my_youtube_password - machine twitch login my_twitch_account_name password my_twitch_password - -To activate authentication with the .netrc file you should pass --netrc -to youtube-dl or place it in the configuration file. - -On Windows you may also need to setup the %HOME% environment variable -manually. - - - -OUTPUT TEMPLATE - - -The -o option allows users to indicate a template for the output file -names. The basic usage is not to set any template arguments when -downloading a single file, like in -youtube-dl -o funny_video.flv "http://some/video". However, it may -contain special sequences that will be replaced when downloading each -video. The special sequences have the format %(NAME)s. To clarify, that -is a percent symbol followed by a name in parentheses, followed by a -lowercase S. Allowed names are: - -- id: Video identifier -- title: Video title -- url: Video URL -- ext: Video filename extension -- alt_title: A secondary title of the video -- display_id: An alternative identifier for the video -- uploader: Full name of the video uploader -- creator: The main artist who created the video -- release_date: The date (YYYYMMDD) when the video was released -- timestamp: UNIX timestamp of the moment the video became available -- upload_date: Video upload date (YYYYMMDD) -- uploader_id: Nickname or id of the video uploader -- location: Physical location where the video was filmed -- duration: Length of the video in seconds -- view_count: How many users have watched the video on the platform -- like_count: Number of positive ratings of the video -- dislike_count: Number of negative ratings of the video -- repost_count: Number of reposts of the video -- average_rating: Average rating give by users, the scale used depends - on the webpage -- comment_count: Number of comments on the video -- age_limit: Age restriction for the video (years) -- format: A human-readable description of the format -- format_id: Format code specified by --format -- format_note: Additional info about the format -- width: Width of the video -- height: Height of the video -- resolution: Textual description of width and height -- tbr: Average bitrate of audio and video in KBit/s -- abr: Average audio bitrate in KBit/s -- acodec: Name of the audio codec in use -- asr: Audio sampling rate in Hertz -- vbr: Average video bitrate in KBit/s -- fps: Frame rate -- vcodec: Name of the video codec in use -- container: Name of the container format -- filesize: The number of bytes, if known in advance -- filesize_approx: An estimate for the number of bytes -- protocol: The protocol that will be used for the actual download -- extractor: Name of the extractor -- extractor_key: Key name of the extractor -- epoch: Unix epoch when creating the file -- autonumber: Five-digit number that will be increased with each - download, starting at zero -- playlist: Name or id of the playlist that contains the video -- playlist_index: Index of the video in the playlist padded with - leading zeros according to the total length of the playlist - -Available for the video that belongs to some logical chapter or section: -- chapter: Name or title of the chapter the video belongs to - -chapter_number: Number of the chapter the video belongs to - chapter_id: -Id of the chapter the video belongs to - -Available for the video that is an episode of some series or programme: -- series: Title of the series or programme the video episode belongs to -- season: Title of the season the video episode belongs to - -season_number: Number of the season the video episode belongs to - -season_id: Id of the season the video episode belongs to - episode: -Title of the video episode - episode_number: Number of the video episode -within a season - episode_id: Id of the video episode - -Each aforementioned sequence when referenced in output template will be -replaced by the actual value corresponding to the sequence name. Note -that some of the sequences are not guaranteed to be present since they -depend on the metadata obtained by particular extractor, such sequences -will be replaced with NA. - -For example for -o %(title)s-%(id)s.%(ext)s and mp4 video with title -youtube-dl test video and id BaW_jenozKcj this will result in a -youtube-dl test video-BaW_jenozKcj.mp4 file created in the current -directory. - -Output template can also contain arbitrary hierarchical path, e.g. --o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' that will -result in downloading each video in a directory corresponding to this -path template. Any missing directory will be automatically created for -you. - -To specify percent literal in output template use %%. To output to -stdout use -o -. - -The current default template is %(title)s-%(id)s.%(ext)s. - -In some cases, you don't want special characters such as 中, spaces, or -&, such as when transferring the downloaded filename to a Windows system -or the filename through an 8bit-unsafe channel. In these cases, add the ---restrict-filenames flag to get a shorter title: - -Examples (note on Windows you may need to use double quotes instead of -single): - - $ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc - youtube-dl test video ''_ä↭𝕐.mp4 # All kinds of weird characters - - $ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc --restrict-filenames - youtube-dl_test_video_.mp4 # A simple file name - - # Download YouTube playlist videos in separate directory indexed by video order in a playlist - $ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re - - # Download Udemy course keeping each chapter in separate directory under MyVideos directory in your home - $ youtube-dl -u user -p password -o '~/MyVideos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/java-tutorial/ - - # Download entire series season keeping each series and each season in separate directory under C:/MyVideos - $ youtube-dl -o "C:/MyVideos/%(series)s/%(season_number)s - %(season)s/%(episode_number)s - %(episode)s.%(ext)s" http://videomore.ru/kino_v_detalayah/5_sezon/367617 - - # Stream the video being downloaded to stdout - $ youtube-dl -o - BaW_jenozKc - - - -FORMAT SELECTION - - -By default youtube-dl tries to download the best available quality, i.e. -if you want the best quality you DON'T NEED to pass any special options, -youtube-dl will guess it for you by DEFAULT. - -But sometimes you may want to download in a different format, for -example when you are on a slow or intermittent connection. The key -mechanism for achieving this is so called _format selection_ based on -which you can explicitly specify desired format, select formats based on -some criterion or criteria, setup precedence and much more. - -The general syntax for format selection is --format FORMAT or shorter --f FORMAT where FORMAT is a _selector expression_, i.e. an expression -that describes format or formats you would like to download. - -The simplest case is requesting a specific format, for example with --f 22 you can download the format with format code equal to 22. You can -get the list of available format codes for particular video using ---list-formats or -F. Note that these format codes are extractor -specific. - -You can also use a file extension (currently 3gp, aac, flv, m4a, mp3, -mp4, ogg, wav, webm are supported) to download best quality format of -particular file extension served as a single file, e.g. -f webm will -download best quality format with webm extension served as a single -file. - -You can also use special names to select particular edge case format: - -best: Select best quality format represented by single file with video -and audio - worst: Select worst quality format represented by single -file with video and audio - bestvideo: Select best quality video only -format (e.g. DASH video), may not be available - worstvideo: Select -worst quality video only format, may not be available - bestaudio: -Select best quality audio only format, may not be available - -worstaudio: Select worst quality audio only format, may not be available - -For example, to download worst quality video only format you can use --f worstvideo. - -If you want to download multiple videos and they don't have the same -formats available, you can specify the order of preference using -slashes. Note that slash is left-associative, i.e. formats on the left -hand side are preferred, for example -f 22/17/18 will download format 22 -if it's available, otherwise it will download format 17 if it's -available, otherwise it will download format 18 if it's available, -otherwise it will complain that no suitable formats are available for -download. - -If you want to download several formats of the same video use comma as a -separator, e.g. -f 22,17,18 will download all these three formats, of -course if they are available. Or more sophisticated example combined -with precedence feature -f 136/137/mp4/bestvideo,140/m4a/bestaudio. - -You can also filter the video formats by putting a condition in -brackets, as in -f "best[height=720]" (or -f "[filesize>10M]"). - -The following numeric meta fields can be used with comparisons <, <=, >, ->=, = (equals), != (not equals): - filesize: The number of bytes, if -known in advance - width: Width of the video, if known - height: Height -of the video, if known - tbr: Average bitrate of audio and video in -KBit/s - abr: Average audio bitrate in KBit/s - vbr: Average video -bitrate in KBit/s - asr: Audio sampling rate in Hertz - fps: Frame rate - -Also filtering work for comparisons = (equals), != (not equals), ^= -(begins with), $= (ends with), *= (contains) and following string meta -fields: - ext: File extension - acodec: Name of the audio codec in use - -vcodec: Name of the video codec in use - container: Name of the -container format - protocol: The protocol that will be used for the -actual download, lower-case. http, https, rtsp, rtmp, rtmpe, m3u8, or -m3u8_native - -Note that none of the aforementioned meta fields are guaranteed to be -present since this solely depends on the metadata obtained by particular -extractor, i.e. the metadata offered by video hoster. - -Formats for which the value is not known are excluded unless you put a -question mark (?) after the operator. You can combine format filters, so --f "[height <=? 720][tbr>500]" selects up to 720p videos (or videos -where the height is not known) with a bitrate of at least 500 KBit/s. - -You can merge the video and audio of two formats into a single file -using -f + (requires ffmpeg or avconv -installed), for example -f bestvideo+bestaudio will download best video -only format, best audio only format and mux them together with -ffmpeg/avconv. - -Format selectors can also be grouped using parentheses, for example if -you want to download the best mp4 and webm formats with a height lower -than 480 you can use -f '(mp4,webm)[height<480]'. - -Since the end of April 2015 and version 2015.04.26 youtube-dl uses --f bestvideo+bestaudio/best as default format selection (see #5447, -#5456). If ffmpeg or avconv are installed this results in downloading -bestvideo and bestaudio separately and muxing them together into a -single file giving the best overall quality available. Otherwise it -falls back to best and results in downloading the best available quality -served as a single file. best is also needed for videos that don't come -from YouTube because they don't provide the audio and video in two -different files. If you want to only download some DASH formats (for -example if you are not interested in getting videos with a resolution -higher than 1080p), you can add --f bestvideo[height<=?1080]+bestaudio/best to your configuration file. -Note that if you use youtube-dl to stream to stdout (and most likely to -pipe it to your media player then), i.e. you explicitly specify output -template as -o -, youtube-dl still uses -f best format selection in -order to start content delivery immediately to your player and not to -wait until bestvideo and bestaudio are downloaded and muxed. - -If you want to preserve the old format selection behavior (prior to -youtube-dl 2015.04.26), i.e. you want to download the best available -quality media served as a single file, you should explicitly specify -your choice with -f best. You may want to add it to the configuration -file in order not to type it every time you run youtube-dl. - -Examples (note on Windows you may need to use double quotes instead of -single): - - # Download best mp4 format available or any other best if no mp4 available - $ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' - - # Download best format available but not better that 480p - $ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' - - # Download best video only format but no bigger that 50 MB - $ youtube-dl -f 'best[filesize<50M]' - - # Download best format available via direct link over HTTP/HTTPS protocol - $ youtube-dl -f '(bestvideo+bestaudio/best)[protocol^=http]' - - - -VIDEO SELECTION - - -Videos can be filtered by their upload date using the options --date, ---datebefore or --dateafter. They accept dates in two formats: - -- Absolute dates: Dates in the format YYYYMMDD. -- Relative dates: Dates in the format - (now|today)[+-][0-9](day|week|month|year)(s)? - -Examples: - - # Download only the videos uploaded in the last 6 months - $ youtube-dl --dateafter now-6months - - # Download only the videos uploaded on January 1, 1970 - $ youtube-dl --date 19700101 - - $ # Download only the videos uploaded in the 200x decade - $ youtube-dl --dateafter 20000101 --datebefore 20091231 - - - -FAQ - - -How do I update youtube-dl? - -If you've followed our manual installation instructions, you can simply -run youtube-dl -U (or, on Linux, sudo youtube-dl -U). - -If you have used pip, a simple sudo pip install -U youtube-dl is -sufficient to update. - -If you have installed youtube-dl using a package manager like _apt-get_ -or _yum_, use the standard system update mechanism to update. Note that -distribution packages are often outdated. As a rule of thumb, youtube-dl -releases at least once a month, and often weekly or even daily. Simply -go to http://yt-dl.org/ to find out the current version. Unfortunately, -there is nothing we youtube-dl developers can do if your distribution -serves a really outdated version. You can (and should) complain to your -distribution in their bugtracker or support forum. - -As a last resort, you can also uninstall the version installed by your -package manager and follow our manual installation instructions. For -that, remove the distribution's package, with a line like - - sudo apt-get remove -y youtube-dl - -Afterwards, simply follow our manual installation instructions: - - sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl - sudo chmod a+x /usr/local/bin/youtube-dl - hash -r - -Again, from then on you'll be able to update with sudo youtube-dl -U. - -I'm getting an error Unable to extract OpenGraph title on YouTube playlists - -YouTube changed their playlist format in March 2014 and later on, so -you'll need at least youtube-dl 2014.07.25 to download all YouTube -videos. - -If you have installed youtube-dl with a package manager, pip, setup.py -or a tarball, please use that to update. Note that Ubuntu packages do -not seem to get updated anymore. Since we are not affiliated with -Ubuntu, there is little we can do. Feel free to report bugs to the -Ubuntu packaging guys - all they have to do is update the package to a -somewhat recent version. See above for a way to update. - -Do I always have to pass -citw? - -By default, youtube-dl intends to have the best options (incidentally, -if you have a convincing case that these should be different, please -file an issue where you explain that). Therefore, it is unnecessary and -sometimes harmful to copy long option strings from webpages. In -particular, the only option out of -citw that is regularly useful is -i. - -Can you please put the -b option back? - -Most people asking this question are not aware that youtube-dl now -defaults to downloading the highest available quality as reported by -YouTube, which will be 1080p or 720p in some cases, so you no longer -need the -b option. For some specific videos, maybe YouTube does not -report them to be available in a specific high quality format you're -interested in. In that case, simply request it with the -f option and -youtube-dl will try to download it. - -I get HTTP error 402 when trying to download a video. What's this? - -Apparently YouTube requires you to pass a CAPTCHA test if you download -too much. We're considering to provide a way to let you solve the -CAPTCHA, but at the moment, your best course of action is pointing a -webbrowser to the youtube URL, solving the CAPTCHA, and restart -youtube-dl. - -Do I need any other programs? - -youtube-dl works fine on its own on most sites. However, if you want to -convert video/audio, you'll need avconv or ffmpeg. On some sites - most -notably YouTube - videos can be retrieved in a higher quality format -without sound. youtube-dl will detect whether avconv/ffmpeg is present -and automatically pick the best option. - -Videos or video formats streamed via RTMP protocol can only be -downloaded when rtmpdump is installed. Downloading MMS and RTSP videos -requires either mplayer or mpv to be installed. - -I have downloaded a video but how can I play it? - -Once the video is fully downloaded, use any video player, such as vlc or -mplayer. - -I extracted a video URL with -g, but it does not play on another machine / in my webbrowser. - -It depends a lot on the service. In many cases, requests for the video -(to download/play it) must come from the same IP address and with the -same cookies. Use the --cookies option to write the required cookies -into a file, and advise your downloader to read cookies from that file. -Some sites also require a common user agent to be used, use ---dump-user-agent to see the one in use by youtube-dl. - -It may be beneficial to use IPv6; in some cases, the restrictions are -only applied to IPv4. Some services (sometimes only for a subset of -videos) do not restrict the video URL by IP address, cookie, or -user-agent, but these are the exception rather than the rule. - -Please bear in mind that some URL protocols are NOT supported by -browsers out of the box, including RTMP. If you are using -g, your own -downloader must support these as well. - -If you want to play the video on a machine that is not running -youtube-dl, you can relay the video content from the machine that runs -youtube-dl. You can use -o - to let youtube-dl stream a video to stdout, -or simply allow the player to download the files written by youtube-dl -in turn. - -ERROR: no fmt_url_map or conn information found in video info - -YouTube has switched to a new video info format in July 2011 which is -not supported by old versions of youtube-dl. See above for how to update -youtube-dl. - -ERROR: unable to download video - -YouTube requires an additional signature since September 2012 which is -not supported by old versions of youtube-dl. See above for how to update -youtube-dl. - -Video URL contains an ampersand and I'm getting some strange output [1] 2839 or 'v' is not recognized as an internal or external command - -That's actually the output from your shell. Since ampersand is one of -the special shell characters it's interpreted by the shell preventing -you from passing the whole URL to youtube-dl. To disable your shell from -interpreting the ampersands (or any other special characters) you have -to either put the whole URL in quotes or escape them with a backslash -(which approach will work depends on your shell). - -For example if your URL is -https://www.youtube.com/watch?t=4&v=BaW_jenozKc you should end up with -following command: - -youtube-dl 'https://www.youtube.com/watch?t=4&v=BaW_jenozKc' - -or - -youtube-dl https://www.youtube.com/watch?t=4\&v=BaW_jenozKc - -For Windows you have to use the double quotes: - -youtube-dl "https://www.youtube.com/watch?t=4&v=BaW_jenozKc" - -ExtractorError: Could not find JS function u'OF' - -In February 2015, the new YouTube player contained a character sequence -in a string that was misinterpreted by old versions of youtube-dl. See -above for how to update youtube-dl. - -HTTP Error 429: Too Many Requests or 402: Payment Required - -These two error codes indicate that the service is blocking your IP -address because of overuse. Contact the service and ask them to unblock -your IP address, or - if you have acquired a whitelisted IP address -already - use the --proxy or --source-address options to select another -IP address. - -SyntaxError: Non-ASCII character - -The error - - File "youtube-dl", line 2 - SyntaxError: Non-ASCII character '\x93' ... - -means you're using an outdated version of Python. Please update to -Python 2.6 or 2.7. - -What is this binary file? Where has the code gone? - -Since June 2012 (#342) youtube-dl is packed as an executable zipfile, -simply unzip it (might need renaming to youtube-dl.zip first on some -systems) or clone the git repository, as laid out above. If you modify -the code, you can run it by executing the __main__.py file. To recompile -the executable, run make youtube-dl. - -The exe throws a _Runtime error from Visual C++_ - -To run the exe you need to install first the Microsoft Visual C++ 2008 -Redistributable Package. - -On Windows, how should I set up ffmpeg and youtube-dl? Where should I put the exe files? - -If you put youtube-dl and ffmpeg in the same directory that you're -running the command from, it will work, but that's rather cumbersome. - -To make a different directory work - either for ffmpeg, or for -youtube-dl, or for both - simply create the directory (say, C:\bin, or -C:\Users\\bin), put all the executables directly in there, -and then set your PATH environment variable to include that directory. - -From then on, after restarting your shell, you will be able to access -both youtube-dl and ffmpeg (and youtube-dl will be able to find ffmpeg) -by simply typing youtube-dl or ffmpeg, no matter what directory you're -in. - -How do I put downloads into a specific folder? - -Use the -o to specify an output template, for example --o "/home/user/videos/%(title)s-%(id)s.%(ext)s". If you want this for -all of your downloads, put the option into your configuration file. - -How do I download a video starting with a -? - -Either prepend http://www.youtube.com/watch?v= or separate the ID from -the options with --: - - youtube-dl -- -wNyEUrxzFU - youtube-dl "http://www.youtube.com/watch?v=-wNyEUrxzFU" - -How do I pass cookies to youtube-dl? - -Use the --cookies option, for example ---cookies /path/to/cookies/file.txt. Note that the cookies file must be -in Mozilla/Netscape format and the first line of the cookies file must -be either # HTTP Cookie File or # Netscape HTTP Cookie File. Make sure -you have correct newline format in the cookies file and convert newlines -if necessary to correspond with your OS, namely CRLF (\r\n) for Windows, -LF (\n) for Linux and CR (\r) for Mac OS. HTTP Error 400: Bad Request -when using --cookies is a good sign of invalid newline format. - -Passing cookies to youtube-dl is a good way to workaround login when a -particular extractor does not implement it explicitly. Another use case -is working around CAPTCHA some websites require you to solve in -particular cases in order to get access (e.g. YouTube, CloudFlare). - -Can you add support for this anime video site, or site which shows current movies for free? - -As a matter of policy (as well as legality), youtube-dl does not include -support for services that specialize in infringing copyright. As a rule -of thumb, if you cannot easily find a video that the service is quite -obviously allowed to distribute (i.e. that has been uploaded by the -creator, the creator's distributor, or is published under a free -license), the service is probably unfit for inclusion to youtube-dl. - -A note on the service that they don't host the infringing content, but -just link to those who do, is evidence that the service should NOT be -included into youtube-dl. The same goes for any DMCA note when the whole -front page of the service is filled with videos they are not allowed to -distribute. A "fair use" note is equally unconvincing if the service -shows copyright-protected videos in full without authorization. - -Support requests for services that DO purchase the rights to distribute -their content are perfectly fine though. If in doubt, you can simply -include a source that mentions the legitimate purchase of content. - -How can I speed up work on my issue? - -(Also known as: Help, my important issue not being solved!) The -youtube-dl core developer team is quite small. While we do our best to -solve as many issues as possible, sometimes that can take quite a while. -To speed up your issue, here's what you can do: - -First of all, please do report the issue at our issue tracker. That -allows us to coordinate all efforts by users and developers, and serves -as a unified point. Unfortunately, the youtube-dl project has grown too -large to use personal email as an effective communication channel. - -Please read the bug reporting instructions below. A lot of bugs lack all -the necessary information. If you can, offer proxy, VPN, or shell access -to the youtube-dl developers. If you are able to, test the issue from -multiple computers in multiple countries to exclude local censorship or -misconfiguration issues. - -If nobody is interested in solving your issue, you are welcome to take -matters into your own hands and submit a pull request (or coerce/pay -somebody else to do so). - -Feel free to bump the issue from time to time by writing a small comment -("Issue is still present in youtube-dl version ...from France, but fixed -from Belgium"), but please not more than once a month. Please do not -declare your issue as important or urgent. - -How can I detect whether a given URL is supported by youtube-dl? - -For one, have a look at the list of supported sites. Note that it can -sometimes happen that the site changes its URL scheme (say, from -http://example.com/video/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. - -It is _not_ possible to detect whether a URL is supported or not. That's -because youtube-dl contains a generic extractor which matches 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. - -If you want to find out whether a given URL is supported, simply call -youtube-dl with it. 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. - - - -DEVELOPER INSTRUCTIONS - - -Most users do not need to build youtube-dl and can download the builds -or get them from their distribution. - -To run youtube-dl as a developer, you don't need to build anything -either. Simply execute - - python -m youtube_dl - -To run the test, simply invoke your favorite test runner, or execute a -test file directly; any of the following work: - - python -m unittest discover - python test/test_download.py - nosetests - -If you want to create a build of youtube-dl yourself, you'll need - -- python -- make -- pandoc -- zip -- nosetests - -Adding support for a new site - -If you want to add support for a new site, you can follow this quick -list (assuming your service is called yourextractor): - -1. Fork this repository -2. Check out the source code with - git clone git@github.com:YOUR_GITHUB_USERNAME/youtube-dl.git -3. Start a new git branch with - cd youtube-dl; git checkout -b yourextractor -4. Start with this simple template and save it to - youtube_dl/extractor/yourextractor.py: - - # coding: utf-8 - from __future__ import unicode_literals - - from .common import InfoExtractor - - - class YourExtractorIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?yourextractor\.com/watch/(?P[0-9]+)' - _TEST = { - 'url': 'http://yourextractor.com/watch/42', - 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', - 'info_dict': { - 'id': '42', - 'ext': 'mp4', - 'title': 'Video title goes here', - 'thumbnail': 're:^https?://.*\.jpg$', - # TODO more properties, either as: - # * A value - # * MD5 checksum; start the string with md5: - # * A regular expression; start the string with re: - # * Any Python type (for example int or float) - } - } - - def _real_extract(self, url): - video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) - - # TODO more code goes here, for example ... - title = self._html_search_regex(r'

(.+?)

', webpage, 'title') - - return { - 'id': video_id, - 'title': title, - 'description': self._og_search_description(webpage), - 'uploader': self._search_regex(r']+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), - # TODO more properties (see youtube_dl/extractor/common.py) - } - -5. Add an import in youtube_dl/extractor/__init__.py. -6. Run python test/test_download.py TestDownload.test_YourExtractor. - This _should fail_ at first, but you can continually re-run it until - you're done. If you decide to add more than one test, then rename - _TEST to _TESTS and make it into a list of dictionaries. The tests - will then be named TestDownload.test_YourExtractor, - TestDownload.test_YourExtractor_1, - TestDownload.test_YourExtractor_2, etc. -7. Have a look at youtube_dl/extractor/common.py for possible helper - methods and a detailed description of what your extractor should and - may return. Add tests and code for as many as you want. -8. If you can, check the code with flake8. -9. When the tests pass, add the new files and commit them and push the - result, like this: - - $ git add youtube_dl/extractor/__init__.py - $ git add youtube_dl/extractor/yourextractor.py - $ git commit -m '[yourextractor] Add new extractor' - $ git push origin yourextractor - -10. Finally, create a pull request. We'll then review and merge it. - -In any case, thank you very much for your contributions! - - - -EMBEDDING YOUTUBE-DL - - -youtube-dl makes the best effort to be a good command-line program, and -thus should be callable from any programming language. If you encounter -any problems parsing its output, feel free to create a report. - -From a Python program, you can embed youtube-dl in a more powerful -fashion, like this: - - from __future__ import unicode_literals - import youtube_dl - - ydl_opts = {} - with youtube_dl.YoutubeDL(ydl_opts) as ydl: - ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc']) - -Most likely, you'll want to use various options. For a list of what can -be done, have a look at youtube_dl/YoutubeDL.py. For a start, if you -want to intercept youtube-dl's output, set a logger object. - -Here's a more complete example of a program that outputs only errors -(and a short message after the download is finished), and -downloads/converts the video to an mp3 file: - - from __future__ import unicode_literals - import youtube_dl - - - class MyLogger(object): - def debug(self, msg): - pass - - def warning(self, msg): - pass - - def error(self, msg): - print(msg) - - - def my_hook(d): - if d['status'] == 'finished': - print('Done downloading, now converting ...') - - - ydl_opts = { - 'format': 'bestaudio/best', - 'postprocessors': [{ - 'key': 'FFmpegExtractAudio', - 'preferredcodec': 'mp3', - 'preferredquality': '192', - }], - 'logger': MyLogger(), - 'progress_hooks': [my_hook], - } - with youtube_dl.YoutubeDL(ydl_opts) as ydl: - ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc']) - - - -BUGS - - -Bugs and suggestions should be reported at: -https://github.com/rg3/youtube-dl/issues. Unless you were prompted so or -there is another pertinent reason (e.g. GitHub fails to accept the bug -report), please do not send bug reports via personal email. For -discussions, join us in the IRC channel #youtube-dl on freenode -(webchat). - -PLEASE INCLUDE THE FULL OUTPUT OF YOUTUBE-DL WHEN RUN WITH -v, i.e. ADD --v flag to YOUR COMMAND LINE, copy the WHOLE output and post it in the -issue body wrapped in ``` for better formatting. It should look similar -to this: - - $ youtube-dl -v - [debug] System config: [] - [debug] User config: [] - [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj'] - [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251 - [debug] youtube-dl version 2015.12.06 - [debug] Git HEAD: 135392e - [debug] Python version 2.6.6 - Windows-2003Server-5.2.3790-SP2 - [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4 - [debug] Proxy map: {} - ... - -DO NOT POST SCREENSHOTS OF VERBOSE LOG ONLY PLAIN TEXT IS ACCEPTABLE. - -The output (including the first lines) contains important debugging -information. Issues without the full output are often not reproducible -and therefore do not get solved in short order, if ever. - -Please re-read your issue once again to avoid a couple of common -mistakes (you can and should use this as a checklist): - -Is the description of the issue itself sufficient? - -We often get issue reports that we cannot really decipher. While in most -cases we eventually get the required information after asking back -multiple times, this poses an unnecessary drain on our resources. Many -contributors, including myself, are also not native speakers, so we may -misread some parts. - -So please elaborate on what feature you are requesting, or what bug you -want to be fixed. Make sure that it's obvious - -- What the problem is -- How it could be fixed -- How your proposed solution would look like - -If your report is shorter than two lines, it is almost certainly missing -some of these, which makes it hard for us to respond to it. We're often -too polite to close the issue outright, but the missing info makes -misinterpretation likely. As a committer myself, I often get frustrated -by these issues, since the only possible way for me to move forward on -them is to ask for clarification over and over. - -For bug reports, this means that your report should contain the -_complete_ output of youtube-dl when called with the -v flag. The error -message you get for (most) bugs even says so, but you would not believe -how many of our bug reports do not contain this information. - -If your server has multiple IPs or you suspect censorship, adding ---call-home may be a good idea to get more diagnostics. If the error is -ERROR: Unable to extract ... and you cannot reproduce it from multiple -countries, add --dump-pages (warning: this will yield a rather large -output, redirect it to the file log.txt by adding >log.txt 2>&1 to your -command-line) or upload the .dump files you get when you add ---write-pages somewhere. - -SITE SUPPORT REQUESTS MUST CONTAIN AN EXAMPLE URL. An example URL is a -URL you might want to download, like -http://www.youtube.com/watch?v=BaW_jenozKc. There should be an obvious -video present. Except under very special circumstances, the main page of -a video service (e.g. http://www.youtube.com/) is _not_ an example URL. - -Are you using the latest version? - -Before reporting any issue, type youtube-dl -U. This should report that -you're up-to-date. About 20% of the reports we receive are already -fixed, but people are using outdated versions. This goes for feature -requests as well. - -Is the issue already documented? - -Make sure that someone has not already opened the issue you're trying to -open. Search at the top of the window or browse the GitHub Issues of -this repository. If there is an issue, feel free to write something -along the lines of "This affects me as well, with version 2015.01.01. -Here is some more information on the issue: ...". While some issues may -be old, a new post into them often spurs rapid activity. - -Why are existing options not enough? - -Before requesting a new feature, please have a quick peek at the list of -supported options. Many feature requests are for features that actually -exist already! Please, absolutely do show off your work in the issue -report and detail how the existing similar options do _not_ solve your -problem. - -Is there enough context in your bug report? - -People want to solve problems, and often think they do us a favor by -breaking down their larger problems (e.g. wanting to skip already -downloaded files) to a specific request (e.g. requesting us to look -whether the file exists before downloading the info page). However, what -often happens is that they break down the problem into two steps: One -simple, and one impossible (or extremely complicated one). - -We are then presented with a very complicated request when the original -problem could be solved far easier, e.g. by recording the downloaded -video IDs in a separate file. To avoid this, you must include the -greater context where it is non-obvious. In particular, every feature -request that does not consist of adding support for a new site should -contain a use case scenario that explains in what situation the missing -feature would be useful. - -Does the issue involve one problem, and one problem only? - -Some of our users seem to think there is a limit of issues they can or -should open. There is no limit of issues they can or should open. While -it may seem appealing to be able to dump all your issues into one -ticket, that means that someone who solves one of your issues cannot -mark the issue as closed. Typically, reporting a bunch of issues leads -to the ticket lingering since nobody wants to attack that behemoth, -until someone mercifully splits the issue into multiple ones. - -In particular, every site support request issue should only pertain to -services at one site (generally under a common domain, but always using -the same backend technology). Do not request support for vimeo user -videos, Whitehouse podcasts, and Google Plus pages in the same issue. -Also, make sure that you don't post bug reports alongside feature -requests. As a rule of thumb, a feature request does not include outputs -of youtube-dl that are not immediately related to the feature at hand. -Do not post reports of a network error alongside the request for a new -video service. - -Is anyone going to need the feature? - -Only post features that you (or an incapacitated friend you can -personally talk to) require. Do not post features because they seem like -a good idea. If they are really useful, they will be requested by -someone who requires them. - -Is your question about youtube-dl? - -It may sound strange, but some bug reports we receive are completely -unrelated to youtube-dl and relate to a different or even the reporter's -own application. Please make sure that you are actually using -youtube-dl. If you are using a UI for youtube-dl, report the bug to the -maintainer of the actual application providing the UI. On the other -hand, if your UI for youtube-dl fails in some way you believe is related -to youtube-dl, by all means, go ahead and report the bug. - - - -COPYRIGHT - - -youtube-dl is released into the public domain by the copyright holders. - -This README file was originally written by Daniel Bolton and is likewise -released into the public domain. diff --git a/devscripts/buildserver.py b/devscripts/buildserver.py index 7c2f49f..fc99c32 100644 --- a/devscripts/buildserver.py +++ b/devscripts/buildserver.py @@ -1,17 +1,38 @@ #!/usr/bin/python3 -from http.server import HTTPServer, BaseHTTPRequestHandler -from socketserver import ThreadingMixIn import argparse import ctypes import functools +import shutil +import subprocess import sys +import tempfile import threading import traceback import os.path +sys.path.insert(0, os.path.dirname(os.path.dirname((os.path.abspath(__file__))))) +from youtube_dl.compat import ( + compat_input, + compat_http_server, + compat_str, + compat_urlparse, +) + +# These are not used outside of buildserver.py thus not in compat.py + +try: + import winreg as compat_winreg +except ImportError: # Python 2 + import _winreg as compat_winreg -class BuildHTTPServer(ThreadingMixIn, HTTPServer): +try: + import socketserver as compat_socketserver +except ImportError: # Python 2 + import SocketServer as compat_socketserver + + +class BuildHTTPServer(compat_socketserver.ThreadingMixIn, compat_http_server.HTTPServer): allow_reuse_address = True @@ -191,7 +212,7 @@ def main(args=None): action='store_const', dest='action', const='service', help='Run as a Windows service') parser.add_argument('-b', '--bind', metavar='', - action='store', default='localhost:8142', + action='store', default='0.0.0.0:8142', help='Bind to host:port (default %default)') options = parser.parse_args(args=args) @@ -216,7 +237,7 @@ def main(args=None): srv = BuildHTTPServer((host, port), BuildHTTPRequestHandler) thr = threading.Thread(target=srv.serve_forever) thr.start() - input('Press ENTER to shut down') + compat_input('Press ENTER to shut down') srv.shutdown() thr.join() @@ -231,8 +252,6 @@ def rmtree(path): os.remove(fname) os.rmdir(path) -#============================================================================== - class BuildError(Exception): def __init__(self, output, code=500): @@ -249,15 +268,25 @@ class HTTPError(BuildError): class PythonBuilder(object): def __init__(self, **kwargs): - pythonVersion = kwargs.pop('python', '2.7') - try: - key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Python\PythonCore\%s\InstallPath' % pythonVersion) + python_version = kwargs.pop('python', '3.4') + python_path = None + for node in ('Wow6432Node\\', ''): try: - self.pythonPath, _ = _winreg.QueryValueEx(key, '') - finally: - _winreg.CloseKey(key) - except Exception: - raise BuildError('No such Python version: %s' % pythonVersion) + key = compat_winreg.OpenKey( + compat_winreg.HKEY_LOCAL_MACHINE, + r'SOFTWARE\%sPython\PythonCore\%s\InstallPath' % (node, python_version)) + try: + python_path, _ = compat_winreg.QueryValueEx(key, '') + finally: + compat_winreg.CloseKey(key) + break + except Exception: + pass + + if not python_path: + raise BuildError('No such Python version: %s' % python_version) + + self.pythonPath = python_path super(PythonBuilder, self).__init__(**kwargs) @@ -305,8 +334,10 @@ class YoutubeDLBuilder(object): def build(self): try: - subprocess.check_output([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], - cwd=self.buildPath) + proc = subprocess.Popen([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], stdin=subprocess.PIPE, cwd=self.buildPath) + proc.wait() + #subprocess.check_output([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], + # cwd=self.buildPath) except subprocess.CalledProcessError as e: raise BuildError(e.output) @@ -369,12 +400,12 @@ class Builder(PythonBuilder, GITBuilder, YoutubeDLBuilder, DownloadBuilder, Clea pass -class BuildHTTPRequestHandler(BaseHTTPRequestHandler): +class BuildHTTPRequestHandler(compat_http_server.BaseHTTPRequestHandler): actionDict = {'build': Builder, 'download': Builder} # They're the same, no more caching. def do_GET(self): - path = urlparse.urlparse(self.path) - paramDict = dict([(key, value[0]) for key, value in urlparse.parse_qs(path.query).items()]) + path = compat_urlparse.urlparse(self.path) + paramDict = dict([(key, value[0]) for key, value in compat_urlparse.parse_qs(path.query).items()]) action, _, path = path.path.strip('/').partition('/') if path: path = path.split('/') @@ -388,7 +419,7 @@ class BuildHTTPRequestHandler(BaseHTTPRequestHandler): builder.close() except BuildError as e: self.send_response(e.code) - msg = unicode(e).encode('UTF-8') + msg = compat_str(e).encode('UTF-8') self.send_header('Content-Type', 'text/plain; charset=UTF-8') self.send_header('Content-Length', len(msg)) self.end_headers() @@ -400,7 +431,5 @@ class BuildHTTPRequestHandler(BaseHTTPRequestHandler): else: self.send_response(500, 'Malformed URL') -#============================================================================== - if __name__ == '__main__': main() diff --git a/devscripts/create-github-release.py b/devscripts/create-github-release.py new file mode 100644 index 0000000..3b8021e --- /dev/null +++ b/devscripts/create-github-release.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +from __future__ import unicode_literals + +import base64 +import json +import mimetypes +import netrc +import optparse +import os +import sys + +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from youtube_dl.compat import ( + compat_basestring, + compat_input, + compat_getpass, + compat_print, + compat_urllib_request, +) +from youtube_dl.utils import ( + make_HTTPS_handler, + sanitized_Request, +) + + +class GitHubReleaser(object): + _API_URL = 'https://api.github.com/repos/rg3/youtube-dl/releases' + _UPLOADS_URL = 'https://uploads.github.com/repos/rg3/youtube-dl/releases/%s/assets?name=%s' + _NETRC_MACHINE = 'github.com' + + def __init__(self, debuglevel=0): + self._init_github_account() + https_handler = make_HTTPS_handler({}, debuglevel=debuglevel) + self._opener = compat_urllib_request.build_opener(https_handler) + + def _init_github_account(self): + try: + info = netrc.netrc().authenticators(self._NETRC_MACHINE) + if info is not None: + self._username = info[0] + self._password = info[2] + compat_print('Using GitHub credentials found in .netrc...') + return + else: + compat_print('No GitHub credentials found in .netrc') + except (IOError, netrc.NetrcParseError): + compat_print('Unable to parse .netrc') + self._username = compat_input( + 'Type your GitHub username or email address and press [Return]: ') + self._password = compat_getpass( + 'Type your GitHub password and press [Return]: ') + + def _call(self, req): + if isinstance(req, compat_basestring): + req = sanitized_Request(req) + # Authorizing manually since GitHub does not response with 401 with + # WWW-Authenticate header set (see + # https://developer.github.com/v3/#basic-authentication) + b64 = base64.b64encode( + ('%s:%s' % (self._username, self._password)).encode('utf-8')).decode('ascii') + req.add_header('Authorization', 'Basic %s' % b64) + response = self._opener.open(req).read().decode('utf-8') + return json.loads(response) + + def list_releases(self): + return self._call(self._API_URL) + + def create_release(self, tag_name, name=None, body='', draft=False, prerelease=False): + data = { + 'tag_name': tag_name, + 'target_commitish': 'master', + 'name': name, + 'body': body, + 'draft': draft, + 'prerelease': prerelease, + } + req = sanitized_Request(self._API_URL, json.dumps(data).encode('utf-8')) + return self._call(req) + + def create_asset(self, release_id, asset): + asset_name = os.path.basename(asset) + url = self._UPLOADS_URL % (release_id, asset_name) + # Our files are small enough to be loaded directly into memory. + data = open(asset, 'rb').read() + req = sanitized_Request(url, data) + mime_type, _ = mimetypes.guess_type(asset_name) + req.add_header('Content-Type', mime_type or 'application/octet-stream') + return self._call(req) + + +def main(): + parser = optparse.OptionParser(usage='%prog VERSION BUILDPATH') + options, args = parser.parse_args() + if len(args) != 2: + parser.error('Expected a version and a build directory') + + version, build_path = args + + releaser = GitHubReleaser() + + new_release = releaser.create_release(version, name='youtube-dl %s' % version) + release_id = new_release['id'] + + for asset in os.listdir(build_path): + compat_print('Uploading %s...' % asset) + releaser.create_asset(release_id, os.path.join(build_path, asset)) + + +if __name__ == '__main__': + main() diff --git a/devscripts/install_srelay.sh b/devscripts/install_srelay.sh new file mode 100755 index 0000000..33ce8a3 --- /dev/null +++ b/devscripts/install_srelay.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +mkdir -p tmp && cd tmp +wget -N http://downloads.sourceforge.net/project/socks-relay/socks-relay/srelay-0.4.8/srelay-0.4.8b6.tar.gz +tar zxvf srelay-0.4.8b6.tar.gz +cd srelay-0.4.8b6 +./configure +make diff --git a/devscripts/lazy_load_template.py b/devscripts/lazy_load_template.py new file mode 100644 index 0000000..2e6e664 --- /dev/null +++ b/devscripts/lazy_load_template.py @@ -0,0 +1,19 @@ +# encoding: utf-8 +from __future__ import unicode_literals + +import re + + +class LazyLoadExtractor(object): + _module = None + + @classmethod + def ie_key(cls): + return cls.__name__[:-2] + + def __new__(cls, *args, **kwargs): + mod = __import__(cls._module, fromlist=(cls.__name__,)) + real_cls = getattr(mod, cls.__name__) + instance = real_cls.__new__(real_cls) + instance.__init__(*args, **kwargs) + return instance diff --git a/devscripts/make_issue_template.py b/devscripts/make_issue_template.py new file mode 100644 index 0000000..b7ad23d --- /dev/null +++ b/devscripts/make_issue_template.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +from __future__ import unicode_literals + +import io +import optparse + + +def main(): + parser = optparse.OptionParser(usage='%prog INFILE OUTFILE') + options, args = parser.parse_args() + if len(args) != 2: + parser.error('Expected an input and an output filename') + + infile, outfile = args + + with io.open(infile, encoding='utf-8') as inf: + issue_template_tmpl = inf.read() + + # Get the version from youtube_dl/version.py without importing the package + exec(compile(open('youtube_dl/version.py').read(), + 'youtube_dl/version.py', 'exec')) + + out = issue_template_tmpl % {'version': locals()['__version__']} + + with io.open(outfile, 'w', encoding='utf-8') as outf: + outf.write(out) + +if __name__ == '__main__': + main() diff --git a/devscripts/make_lazy_extractors.py b/devscripts/make_lazy_extractors.py new file mode 100644 index 0000000..9a79c2b --- /dev/null +++ b/devscripts/make_lazy_extractors.py @@ -0,0 +1,98 @@ +from __future__ import unicode_literals, print_function + +from inspect import getsource +import os +from os.path import dirname as dirn +import sys + +print('WARNING: Lazy loading extractors is an experimental feature that may not always work', file=sys.stderr) + +sys.path.insert(0, dirn(dirn((os.path.abspath(__file__))))) + +lazy_extractors_filename = sys.argv[1] +if os.path.exists(lazy_extractors_filename): + os.remove(lazy_extractors_filename) + +from youtube_dl.extractor import _ALL_CLASSES +from youtube_dl.extractor.common import InfoExtractor, SearchInfoExtractor + +with open('devscripts/lazy_load_template.py', 'rt') as f: + module_template = f.read() + +module_contents = [ + module_template + '\n' + getsource(InfoExtractor.suitable) + '\n', + 'class LazyLoadSearchExtractor(LazyLoadExtractor):\n pass\n'] + +ie_template = ''' +class {name}({bases}): + _VALID_URL = {valid_url!r} + _module = '{module}' +''' + +make_valid_template = ''' + @classmethod + def _make_valid_url(cls): + return {valid_url!r} +''' + + +def get_base_name(base): + if base is InfoExtractor: + return 'LazyLoadExtractor' + elif base is SearchInfoExtractor: + return 'LazyLoadSearchExtractor' + else: + return base.__name__ + + +def build_lazy_ie(ie, name): + valid_url = getattr(ie, '_VALID_URL', None) + s = ie_template.format( + name=name, + bases=', '.join(map(get_base_name, ie.__bases__)), + valid_url=valid_url, + module=ie.__module__) + if ie.suitable.__func__ is not InfoExtractor.suitable.__func__: + s += '\n' + getsource(ie.suitable) + if hasattr(ie, '_make_valid_url'): + # search extractors + s += make_valid_template.format(valid_url=ie._make_valid_url()) + return s + +# find the correct sorting and add the required base classes so that sublcasses +# can be correctly created +classes = _ALL_CLASSES[:-1] +ordered_cls = [] +while classes: + for c in classes[:]: + bases = set(c.__bases__) - set((object, InfoExtractor, SearchInfoExtractor)) + stop = False + for b in bases: + if b not in classes and b not in ordered_cls: + if b.__name__ == 'GenericIE': + exit() + classes.insert(0, b) + stop = True + if stop: + break + if all(b in ordered_cls for b in bases): + ordered_cls.append(c) + classes.remove(c) + break +ordered_cls.append(_ALL_CLASSES[-1]) + +names = [] +for ie in ordered_cls: + name = ie.__name__ + src = build_lazy_ie(ie, name) + module_contents.append(src) + if ie in _ALL_CLASSES: + names.append(name) + +module_contents.append( + '_ALL_CLASSES = [{0}]'.format(', '.join(names))) + +module_src = '\n'.join(module_contents) + '\n' + +with open(lazy_extractors_filename, 'wt') as f: + f.write(module_src) diff --git a/devscripts/prepare_manpage.py b/devscripts/prepare_manpage.py index 776e655..e3f6339 100644 --- a/devscripts/prepare_manpage.py +++ b/devscripts/prepare_manpage.py @@ -1,13 +1,46 @@ from __future__ import unicode_literals import io +import optparse import os.path -import sys import re ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) README_FILE = os.path.join(ROOT_DIR, 'README.md') +PREFIX = '''%YOUTUBE-DL(1) + +# NAME + +youtube\-dl \- download videos from youtube.com or other video platforms + +# SYNOPSIS + +**youtube-dl** \[OPTIONS\] URL [URL...] + +''' + + +def main(): + parser = optparse.OptionParser(usage='%prog OUTFILE.md') + options, args = parser.parse_args() + if len(args) != 1: + parser.error('Expected an output filename') + + outfile, = args + + with io.open(README_FILE, encoding='utf-8') as f: + readme = f.read() + + readme = re.sub(r'(?s)^.*?(?=# DESCRIPTION)', '', readme) + readme = re.sub(r'\s+youtube-dl \[OPTIONS\] URL \[URL\.\.\.\]', '', readme) + readme = PREFIX + readme + + readme = filter_options(readme) + + with io.open(outfile, 'w', encoding='utf-8') as outf: + outf.write(readme) + def filter_options(readme): ret = '' @@ -37,27 +70,5 @@ def filter_options(readme): return ret -with io.open(README_FILE, encoding='utf-8') as f: - readme = f.read() - -PREFIX = '''%YOUTUBE-DL(1) - -# NAME - -youtube\-dl \- download videos from youtube.com or other video platforms - -# SYNOPSIS - -**youtube-dl** \[OPTIONS\] URL [URL...] - -''' -readme = re.sub(r'(?s)^.*?(?=# DESCRIPTION)', '', readme) -readme = re.sub(r'\s+youtube-dl \[OPTIONS\] URL \[URL\.\.\.\]', '', readme) -readme = PREFIX + readme - -readme = filter_options(readme) - -if sys.version_info < (3, 0): - print(readme.encode('utf-8')) -else: - print(readme) +if __name__ == '__main__': + main() diff --git a/devscripts/release.sh b/devscripts/release.sh index 6180696..f8d466b 100755 --- a/devscripts/release.sh +++ b/devscripts/release.sh @@ -6,7 +6,7 @@ # * the git config user.signingkey is properly set # You will need -# pip install coverage nose rsa +# pip install coverage nose rsa wheel # TODO # release notes @@ -15,10 +15,33 @@ set -e skip_tests=true -if [ "$1" = '--run-tests' ]; then - skip_tests=false - shift -fi +gpg_sign_commits="" +buildserver='localhost:8142' + +while true +do +case "$1" in + --run-tests) + skip_tests=false + shift + ;; + --gpg-sign-commits|-S) + gpg_sign_commits="-S" + shift + ;; + --buildserver) + buildserver="$2" + shift 2 + ;; + --*) + echo "ERROR: unknown option $1" + exit 1 + ;; + *) + break + ;; +esac +done if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi version="$1" @@ -33,6 +56,9 @@ if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: th useless_files=$(find youtube_dl -type f -not -name '*.py') if [ ! -z "$useless_files" ]; then echo "ERROR: Non-.py files in youtube_dl: $useless_files"; exit 1; fi if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi +if ! type pandoc >/dev/null 2>/dev/null; then echo 'ERROR: pandoc is missing'; exit 1; fi +if ! python3 -c 'import rsa' 2>/dev/null; then echo 'ERROR: python3-rsa is missing'; exit 1; fi +if ! python3 -c 'import wheel' 2>/dev/null; then echo 'ERROR: wheel is missing'; exit 1; fi /bin/echo -e "\n### First of all, testing..." make clean @@ -45,10 +71,10 @@ fi /bin/echo -e "\n### Changing version in version.py..." sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py -/bin/echo -e "\n### Committing documentation and youtube_dl/version.py..." -make README.md CONTRIBUTING.md supportedsites -git add README.md CONTRIBUTING.md docs/supportedsites.md youtube_dl/version.py -git commit -m "release $version" +/bin/echo -e "\n### Committing documentation, templates and youtube_dl/version.py..." +make README.md CONTRIBUTING.md .github/ISSUE_TEMPLATE.md supportedsites +git add README.md CONTRIBUTING.md .github/ISSUE_TEMPLATE.md docs/supportedsites.md youtube_dl/version.py +git commit $gpg_sign_commits -m "release $version" /bin/echo -e "\n### Now tagging, signing and pushing..." git tag -s -m "Release $version" "$version" @@ -64,7 +90,7 @@ git push origin "$version" REV=$(git rev-parse HEAD) make youtube-dl youtube-dl.tar.gz read -p "VM running? (y/n) " -n 1 -wget "http://localhost:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe +wget "http://$buildserver/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe mkdir -p "build/$version" mv youtube-dl youtube-dl.exe "build/$version" mv youtube-dl.tar.gz "build/$version/youtube-dl-$version.tar.gz" @@ -74,15 +100,16 @@ RELEASE_FILES="youtube-dl youtube-dl.exe youtube-dl-$version.tar.gz" (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS) (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS) -/bin/echo -e "\n### Signing and uploading the new binaries to yt-dl.org ..." +/bin/echo -e "\n### Signing and uploading the new binaries to GitHub..." for f in $RELEASE_FILES; do gpg --passphrase-repeat 5 --detach-sig "build/$version/$f"; done -scp -r "build/$version" ytdl@yt-dl.org:html/tmp/ -ssh ytdl@yt-dl.org "mv html/tmp/$version html/downloads/" + +ROOT=$(pwd) +python devscripts/create-github-release.py $version "$ROOT/build/$version" + ssh ytdl@yt-dl.org "sh html/update_latest.sh $version" /bin/echo -e "\n### Now switching to gh-pages..." git clone --branch gh-pages --single-branch . build/gh-pages -ROOT=$(pwd) ( set -e ORIGIN_URL=$(git config --get remote.origin.url) @@ -94,7 +121,7 @@ ROOT=$(pwd) "$ROOT/devscripts/gh-pages/update-copyright.py" "$ROOT/devscripts/gh-pages/update-sites.py" git add *.html *.html.in update - git commit -m "release $version" + git commit $gpg_sign_commits -m "release $version" git push "$ROOT" gh-pages git push "$ORIGIN_URL" gh-pages ) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 7459615..891499f 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -6,6 +6,7 @@ - **22tracks:genre** - **22tracks:track** - **24video** + - **3qsdn**: 3Q SDN - **3sat** - **4tube** - **56.com** @@ -15,6 +16,8 @@ - **9gag** - **abc.net.au** - **Abc7News** + - **abcnews** + - **abcnews:video** - **AcademicEarth:Course** - **acast** - **acast:channel** @@ -25,6 +28,7 @@ - **AdobeTVVideo** - **AdultSwim** - **aenetworks**: A+E Networks: A&E, Lifetime, History.com, FYI Network + - **AfreecaTV**: afreecatv.com - **Aftonbladet** - **AirMozilla** - **AlJazeera** @@ -40,8 +44,8 @@ - **appletrailers:section** - **archive.org**: archive.org videos - **ARD** - - **ARD:mediathek**: Saarländischer Rundfunk - **ARD:mediathek** + - **ARD:mediathek**: Saarländischer Rundfunk - **arte.tv** - **arte.tv:+7** - **arte.tv:cinema** @@ -50,12 +54,16 @@ - **arte.tv:ddc** - **arte.tv:embed** - **arte.tv:future** + - **arte.tv:info** - **arte.tv:magazine** + - **arte.tv:playlist** - **AtresPlayer** - **ATTTechChannel** - **AudiMedia** + - **AudioBoom** - **audiomack** - **audiomack:album** + - **auroravid**: AuroraVid - **Azubu** - **AzubuLive** - **BaiduVideo**: 百度视频 @@ -66,6 +74,8 @@ - **bbc**: BBC - **bbc.co.uk**: BBC iPlayer - **bbc.co.uk:article**: BBC articles + - **bbc.co.uk:iplayer:playlist** + - **bbc.co.uk:playlist** - **BeatportPro** - **Beeg** - **BehindKink** @@ -73,12 +83,16 @@ - **Bigflix** - **Bild**: Bild.de - **BiliBili** + - **BioBioChileTV** + - **BIQLE** - **BleacherReport** - **BleacherReportCMS** - **blinkx** - **Bloomberg** + - **BokeCC** - **Bpb**: Bundeszentrale für politische Bildung - **BR**: Bayerischer Rundfunk Mediathek + - **BravoTV** - **Break** - **brightcove:legacy** - **brightcove:new** @@ -88,15 +102,21 @@ - **BYUtv** - **Camdemy** - **CamdemyFolder** + - **CamWithHer** - **canalc2.tv** - **Canalplus**: canalplus.fr, piwiplus.fr and d8.tv - **Canvas** + - **CarambaTV** + - **CarambaTVPage** - **CBC** - **CBCPlayer** - **CBS** + - **CBSInteractive** + - **CBSLocal** - **CBSNews**: CBS News - **CBSNewsLiveVideo**: CBS News Live Videos - **CBSSports** + - **CDA** - **CeskaTelevize** - **channel9**: Channel 9 - **Chaturbate** @@ -104,36 +124,39 @@ - **chirbit** - **chirbit:profile** - **Cinchcast** - - **Cinemassacre** - **Clipfish** - **cliphunter** + - **ClipRs** - **Clipsyndicate** + - **CloserToTruth** - **cloudtime**: CloudTime - **Cloudy** - **Clubic** - **Clyp** - **cmt.com** - - **CNET** + - **CNBC** - **CNN** - **CNNArticle** - **CNNBlogs** - - **CollegeHumor** - **CollegeRama** - **ComCarCoff** - **ComedyCentral** - **ComedyCentralShows**: The Daily Show / The Colbert Report - **CondeNast**: Condé Nast media group: Allure, Architectural Digest, Ars Technica, Bon Appétit, Brides, Condé Nast, Condé Nast Traveler, Details, Epicurious, GQ, Glamour, Golf Digest, SELF, Teen Vogue, The New Yorker, Vanity Fair, Vogue, W Magazine, WIRED + - **Coub** - **Cracked** - **Crackle** - **Criterion** - **CrooksAndLiars** - **Crunchyroll** - **crunchyroll:playlist** + - **CSNNE** - **CSpan**: C-SPAN - **CtsNews**: 華視新聞 - **culturebox.francetvinfo.fr** - **CultureUnplugged** - **CWTV** + - **DailyMail** - **dailymotion** - **dailymotion:playlist** - **dailymotion:user** @@ -152,6 +175,7 @@ - **defense.gouv.fr** - **democracynow** - **DHM**: Filmarchiv - Deutsches Historisches Museum + - **DigitallySpeaking** - **Digiteka** - **Discovery** - **Dotsub** @@ -163,9 +187,10 @@ - **Dropbox** - **DrTuber** - **DRTV** - - **Dump** - **Dumpert** - **dvtv**: http://video.aktualne.cz/ + - **dw** + - **dw:article** - **EaglePlatform** - **EbaumsWorld** - **EchoMsk** @@ -188,17 +213,19 @@ - **exfm**: ex.fm - **ExpoTV** - **ExtremeTube** + - **EyedoTV** - **facebook** - - **facebook:post** - **faz.net** - **fc2** - **Fczenit** + - **features.aol.com** - **fernsehkritik.tv** - **Firstpost** - **FiveTV** - **Flickr** - **Folketinget**: Folketinget (ft.dk; Danish parliament) - **FootyRoom** + - **Formula1** - **FOX** - **Foxgay** - **FoxNews**: Fox News and Fox Business Video @@ -221,7 +248,6 @@ - **Gamersyde** - **GameSpot** - **GameStar** - - **Gametrailers** - **Gazeta** - **GDCVault** - **generic**: Generic downloader that works on some sites @@ -232,6 +258,7 @@ - **Globo** - **GloboArticle** - **GodTube** + - **GodTV** - **GoldenMoustache** - **Golem** - **GoogleDrive** @@ -239,6 +266,7 @@ - **GPUTechConf** - **Groupon** - **Hark** + - **HBO** - **HearThisAt** - **Heise** - **HellPorno** @@ -274,7 +302,6 @@ - **ivi:compilation**: ivi.ru compilations - **ivideon**: Ivideon TV - **Izlesene** - - **JadoreCettePub** - **JeuxVideo** - **Jove** - **jpopsuki.tv** @@ -292,6 +319,7 @@ - **kontrtube**: KontrTube.ru - Труба зовёт - **KrasView**: Красвью - **Ku6** + - **KUSI** - **kuwo:album**: 酷我音乐 - 专辑 - **kuwo:category**: 酷我音乐 - 分类 - **kuwo:chart**: 酷我音乐 - 排行榜 @@ -300,22 +328,25 @@ - **kuwo:song**: 酷我音乐 - **la7.tv** - **Laola1Tv** + - **Le**: 乐视网 + - **Learnr** - **Lecture2Go** - **Lemonde** - - **Letv**: 乐视网 + - **LePlaylist** - **LetvCloud**: 乐视云 - - **LetvPlaylist** - - **LetvTv** - **Libsyn** + - **life**: Life.ru - **life:embed** - - **lifenews**: LIFE | NEWS - **limelight** - **limelight:channel** - **limelight:channel_list** + - **LiTV** - **LiveLeak** - **livestream** - **livestream:original** - **LnkGo** + - **loc**: Library of Congress + - **LocalNews8** - **LoveHomePorn** - **lrt.lt** - **lynda**: lynda.com videos @@ -323,25 +354,30 @@ - **m6** - **macgamestore**: MacGameStore trailers - **mailru**: Видео@Mail.Ru + - **MakersChannel** - **MakerTV** - - **Malemotion** - **MatchTV** - **MDR**: MDR.DE and KiKA - **media.ccc.de** - **metacafe** - **Metacritic** - **Mgoon** + - **MGTV**: 芒果TV - **Minhateca** - **MinistryGrid** + - **Minoto** - **miomio.tv** - **MiTele**: mitele.es - **mixcloud** + - **mixcloud:playlist** + - **mixcloud:stream** + - **mixcloud:user** - **MLB** + - **Mnet** - **MoeVideo**: LetitBit video services: moevideo.net, playreplay.net and videochart.net - **Mofosex** - **Mojvideo** - **Moniker**: allmyvideos.net and vidspot.net - - **mooshare**: Mooshare.biz - **Morningstar**: morningstar.com - **Motherless** - **Motorsport**: motorsport.com @@ -349,15 +385,16 @@ - **MovieFap** - **Moviezine** - **MPORA** - - **MSNBC** - **MTV** - **mtv.de** - **mtviggy.com** - **mtvservices:embedded** - **MuenchenTV**: münchen.tv - **MusicPlayOn** - - **muzu.tv** + - **mva**: Microsoft Virtual Academy videos + - **mva:course**: Microsoft Virtual Academy courses - **Mwave** + - **MwaveMeetGreet** - **MySpace** - **MySpace:album** - **MySpass** @@ -365,7 +402,8 @@ - **myvideo** (Currently broken) - **MyVidster** - **n-tv.de** - - **NationalGeographic** + - **natgeo** + - **natgeo:channel** - **Naver** - **NBA** - **NBC** @@ -377,7 +415,6 @@ - **ndr:embed:base** - **NDTV** - **NerdCubedFeed** - - **Nerdist** - **netease:album**: 网易云音乐 - 专辑 - **netease:djradio**: 网易云音乐 - 电台 - **netease:mv**: 网易云音乐 - MV @@ -395,8 +432,10 @@ - **nfl.com** - **nhl.com** - **nhl.com:news**: NHL news - - **nhl.com:videocenter**: NHL videocenter category + - **nhl.com:videocenter** + - **nhl.com:videocenter:category**: NHL videocenter category - **nick.com** + - **nick.de** - **niconico**: ニコニコ動画 - **NiconicoPlaylist** - **njoy**: N-JOY @@ -405,7 +444,6 @@ - **Normalboots** - **NosVideo** - **Nova**: TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz - - **novamov**: NovaMov - **nowness** - **nowness:playlist** - **nowness:series** @@ -420,6 +458,7 @@ - **Npr** - **NRK** - **NRKPlaylist** + - **NRKSkole**: NRK Skole - **NRKTV**: NRK TV and NRK Radio - **ntv.ru** - **Nuvid** @@ -432,6 +471,7 @@ - **OnionStudios** - **Ooyala** - **OoyalaExternal** + - **Openload** - **OraTV** - **orf:fm4**: radio FM4 - **orf:iptv**: iptv.ORF.at @@ -442,13 +482,14 @@ - **Patreon** - **pbs**: Public Broadcasting Service (PBS) and member stations: PBS: Public Broadcasting Service, APT - Alabama Public Television (WBIQ), GPB/Georgia Public Broadcasting (WGTV), Mississippi Public Broadcasting (WMPN), Nashville Public Television (WNPT), WFSU-TV (WFSU), WSRE (WSRE), WTCI (WTCI), WPBA/Channel 30 (WPBA), Alaska Public Media (KAKM), Arizona PBS (KAET), KNME-TV/Channel 5 (KNME), Vegas PBS (KLVX), AETN/ARKANSAS ETV NETWORK (KETS), KET (WKLE), WKNO/Channel 10 (WKNO), LPB/LOUISIANA PUBLIC BROADCASTING (WLPB), OETA (KETA), Ozarks Public Television (KOZK), WSIU Public Broadcasting (WSIU), KEET TV (KEET), KIXE/Channel 9 (KIXE), KPBS San Diego (KPBS), KQED (KQED), KVIE Public Television (KVIE), PBS SoCal/KOCE (KOCE), ValleyPBS (KVPT), CONNECTICUT PUBLIC TELEVISION (WEDH), KNPB Channel 5 (KNPB), SOPTV (KSYS), Rocky Mountain PBS (KRMA), KENW-TV3 (KENW), KUED Channel 7 (KUED), Wyoming PBS (KCWC), Colorado Public Television / KBDI 12 (KBDI), KBYU-TV (KBYU), Thirteen/WNET New York (WNET), WGBH/Channel 2 (WGBH), WGBY (WGBY), NJTV Public Media NJ (WNJT), WLIW21 (WLIW), mpt/Maryland Public Television (WMPB), WETA Television and Radio (WETA), WHYY (WHYY), PBS 39 (WLVT), WVPT - Your Source for PBS and More! (WVPT), Howard University Television (WHUT), WEDU PBS (WEDU), WGCU Public Media (WGCU), WPBT2 (WPBT), WUCF TV (WUCF), WUFT/Channel 5 (WUFT), WXEL/Channel 42 (WXEL), WLRN/Channel 17 (WLRN), WUSF Public Broadcasting (WUSF), ETV (WRLK), UNC-TV (WUNC), PBS Hawaii - Oceanic Cable Channel 10 (KHET), Idaho Public Television (KAID), KSPS (KSPS), OPB (KOPB), KWSU/Channel 10 & KTNW/Channel 31 (KWSU), WILL-TV (WILL), Network Knowledge - WSEC/Springfield (WSEC), WTTW11 (WTTW), Iowa Public Television/IPTV (KDIN), Nine Network (KETC), PBS39 Fort Wayne (WFWA), WFYI Indianapolis (WFYI), Milwaukee Public Television (WMVS), WNIN (WNIN), WNIT Public Television (WNIT), WPT (WPNE), WVUT/Channel 22 (WVUT), WEIU/Channel 51 (WEIU), WQPT-TV (WQPT), WYCC PBS Chicago (WYCC), WIPB-TV (WIPB), WTIU (WTIU), CET (WCET), ThinkTVNetwork (WPTD), WBGU-TV (WBGU), WGVU TV (WGVU), NET1 (KUON), Pioneer Public Television (KWCM), SDPB Television (KUSD), TPT (KTCA), KSMQ (KSMQ), KPTS/Channel 8 (KPTS), KTWU/Channel 11 (KTWU), East Tennessee PBS (WSJK), WCTE-TV (WCTE), WLJT, Channel 11 (WLJT), WOSU TV (WOSU), WOUB/WOUC (WOUB), WVPB (WVPB), WKYU-PBS (WKYU), KERA 13 (KERA), MPBN (WCBB), Mountain Lake PBS (WCFE), NHPTV (WENH), Vermont PBS (WETK), witf (WITF), WQED Multimedia (WQED), WMHT Educational Telecommunications (WMHT), Q-TV (WDCQ), WTVS Detroit Public TV (WTVS), CMU Public Television (WCMU), WKAR-TV (WKAR), WNMU-TV Public TV 13 (WNMU), WDSE - WRPT (WDSE), WGTE TV (WGTE), Lakeland Public Television (KAWE), KMOS-TV - Channels 6.1, 6.2 and 6.3 (KMOS), MontanaPBS (KUSM), KRWG/Channel 22 (KRWG), KACV (KACV), KCOS/Channel 13 (KCOS), WCNY/Channel 24 (WCNY), WNED (WNED), WPBS (WPBS), WSKG Public TV (WSKG), WXXI (WXXI), WPSU (WPSU), WVIA Public Media Studios (WVIA), WTVI (WTVI), Western Reserve PBS (WNEO), WVIZ/PBS ideastream (WVIZ), KCTS 9 (KCTS), Basin PBS (KPBT), KUHT / Channel 8 (KUHT), KLRN (KLRN), KLRU (KLRU), WTJX Channel 12 (WTJX), WCVE PBS (WCVE), KBTC Public Television (KBTC) - **pcmag** - - **Periscope**: Periscope + - **People** + - **periscope**: Periscope + - **periscope:user**: Periscope user videos - **PhilharmonieDeParis**: Philharmonie de Paris - **phoenix.de** - **Photobucket** - **Pinkbike** - **Pladform** - - **PlanetaPlay** - **play.fm** - **played.to** - **PlaysTV** @@ -467,6 +508,7 @@ - **Pornotube** - **PornoVoisines** - **PornoXO** + - **PressTV** - **PrimeShareTV** - **PromptFile** - **prosiebensat1**: ProSiebenSat.1 Digital @@ -477,10 +519,12 @@ - **qqmusic:playlist**: QQ音乐 - 歌单 - **qqmusic:singer**: QQ音乐 - 歌手 - **qqmusic:toplist**: QQ音乐 - 排行榜 - - **QuickVid** - **R7** + - **R7Article** - **radio.de** - **radiobremen** + - **radiocanada** + - **RadioCanadaAudioVideo** - **radiofrance** - **RadioJavan** - **Rai** @@ -490,9 +534,13 @@ - **RedTube** - **RegioTV** - **Restudy** + - **Reuters** - **ReverbNation** - - **Revision3** + - **revision** + - **revision3:embed** + - **RICE** - **RingTV** + - **RockstarGames** - **RottenTomatoes** - **Roxwel** - **RTBF** @@ -516,6 +564,7 @@ - **RUTV**: RUTV.RU - **Ruutu** - **safari**: safaribooksonline.com online video + - **safari:api** - **safari:course**: safaribooksonline.com online courses - **Sandia**: Sandia National Laboratories - **Sapo**: SAPO Vídeos @@ -528,10 +577,11 @@ - **ScreencastOMatic** - **ScreenJunkies** - **ScreenwaveMedia** + - **Seeker** - **SenateISVP** + - **SendtoNews** - **ServingSys** - **Sexu** - - **SexyKarma**: Sexy Karma and Watch Indian Porn - **Shahid** - **Shared**: shared.sx and vivo.sx - **ShareSix** @@ -544,8 +594,6 @@ - **smotri:broadcast**: Smotri.com broadcasts - **smotri:community**: Smotri.com community videos - **smotri:user**: Smotri.com user videos - - **SnagFilms** - - **SnagFilmsEmbed** - **Snotr** - **Sohu** - **soundcloud** @@ -560,7 +608,6 @@ - **southpark.de** - **southpark.nl** - **southparkstudios.dk** - - **Space** - **SpankBang** - **Spankwire** - **Spiegel** @@ -588,8 +635,10 @@ - **Syfy** - **SztvHu** - **Tagesschau** + - **tagesschau:player** - **Tapely** - **Tass** + - **TDSLifeway** - **teachertube**: teachertube.com videos - **teachertube:user:collection**: teachertube.com user and collection videos - **TeachingChannel** @@ -604,13 +653,14 @@ - **Telegraaf** - **TeleMB** - **TeleTask** - - **TenPlay** + - **Telewebion** - **TF1** - **TheIntercept** - - **TheOnion** - **ThePlatform** - **ThePlatformFeed** + - **TheScene** - **TheSixtyOne** + - **TheStar** - **ThisAmericanLife** - **ThisAV** - **THVideo** @@ -620,6 +670,7 @@ - **TMZ** - **TMZArticle** - **TNAFlix** + - **TNAFlixNetworkEmbed** - **toggle** - **tou.tv** - **Toypics**: Toypics user profile @@ -643,17 +694,18 @@ - **tv.dfb.de** - **TV2** - **TV2Article** + - **TV3** - **TV4**: tv4.se and tv4play.se - **TVC** - **TVCArticle** - **tvigle**: Интернет-телевидение Tvigle.ru - **tvland.com** - - **tvp.pl** - - **tvp.pl:Series** + - **tvp**: Telewizja Polska + - **tvp:series** - **TVPlay**: TV3Play and related services - **Tweakers** - - **twitch:bookmarks** - **twitch:chapter** + - **twitch:clips** - **twitch:past_broadcasts** - **twitch:profile** - **twitch:stream** @@ -662,14 +714,16 @@ - **twitter** - **twitter:amplify** - **twitter:card** - - **Ubu** - **udemy** - **udemy:course** - **UDNEmbed**: 聯合影音 - **Unistra** - **Urort**: NRK P3 Urørt + - **USAToday** - **ustream** - **ustream:channel** + - **ustudio** + - **ustudio:embed** - **Varzesh3** - **Vbox7** - **VeeHD** @@ -677,27 +731,32 @@ - **Vessel** - **Vesti**: Вести.Ru - **Vevo** + - **VevoPlaylist** - **VGTV**: VGTV, BTTV, FTV, Aftenposten and Aftonbladet - **vh1.com** - **Vice** + - **ViceShow** - **Viddler** - **video.google:search**: Google Video search - **video.mit.edu** - **VideoDetective** - **videofy.me** - - **VideoMega** (Currently broken) + - **VideoMega** - **videomore** - **videomore:season** - **videomore:video** - **VideoPremium** - **VideoTt**: video.tt - Your True Tube (Currently broken) - **videoweed**: VideoWeed + - **Vidio** - **vidme** - **vidme:user** - **vidme:user:likes** - **Vidzi** - **vier** - **vier:videos** + - **ViewLift** + - **ViewLiftEmbed** - **Viewster** - **Viidea** - **viki** @@ -707,6 +766,7 @@ - **vimeo:channel** - **vimeo:group** - **vimeo:likes**: Vimeo user likes + - **vimeo:ondemand** - **vimeo:review**: Review pages on vimeo - **vimeo:user** - **vimeo:watchlater**: Vimeo watch later list, "vimeowatchlater" keyword (requires authentication) @@ -718,22 +778,21 @@ - **vlive** - **Vodlocker** - **VoiceRepublic** + - **VoxMedia** - **Vporn** - **vpro**: npo.nl and ntr.nl - **VRT** - **vube**: Vube.com - **VuClip** - - **vulture.com** - **Walla** - - **WashingtonPost** + - **washingtonpost** + - **washingtonpost:article** - **wat.tv** - - **WayOfTheMaster** + - **WatchIndianPorn**: Watch Indian Porn - **WDR** - **wdr:mobile** - - **WDRMaus**: Sendung mit der Maus - **WebOfStories** - **WebOfStoriesPlaylist** - - **Weibo** - **WeiqiTV**: WQTV - **wholecloud**: WholeCloud - **Wimp** @@ -741,12 +800,17 @@ - **WNL** - **WorldStarHipHop** - **wrzuta.pl** + - **wrzuta.pl:playlist** - **WSJ**: Wall Street Journal - **XBef** - **XboxClips** - - **XFileShare**: XFileShare based sites: GorillaVid.in, daclips.in, movpod.in, fastvideo.in, realvid.net, filehoot.com and vidto.me + - **XFileShare**: XFileShare based sites: DaClips, FileHoot, GorillaVid, MovPod, PowerWatch, Rapidvideo.ws, TheVideoBee, Vidto, Streamin.To, XVIDSTAGE - **XHamster** - **XHamsterEmbed** + - **xiami:album**: 虾米音乐 - 专辑 + - **xiami:artist**: 虾米音乐 - 歌手 + - **xiami:collection**: 虾米音乐 - 精选集 + - **xiami:song**: 虾米音乐 - **XMinus** - **XNXX** - **Xstream** @@ -765,12 +829,14 @@ - **Ynet** - **YouJizz** - **youku**: 优酷 + - **youku:show** - **YouPorn** - **YourUpload** - **youtube**: YouTube.com - **youtube:channel**: YouTube.com channels - **youtube:favorites**: YouTube.com favourite videos, ":ytfav" for short (requires authentication) - **youtube:history**: Youtube watch history, ":ythistory" for short (requires authentication) + - **youtube:live**: YouTube.com live streams - **youtube:playlist**: YouTube.com playlists - **youtube:playlists**: YouTube.com user/channel playlists - **youtube:recommended**: YouTube.com recommended videos, ":ytrec" for short (requires authentication) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2dc06ff --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[wheel] +universal = True + +[flake8] +exclude = youtube_dl/extractor/__init__.py,devscripts/buildserver.py,devscripts/lazy_load_template.py,devscripts/make_issue_template.py,setup.py,build,.git +ignore = E402,E501,E731 diff --git a/setup.py b/setup.py index bfe931f..508b27f 100644 --- a/setup.py +++ b/setup.py @@ -8,11 +8,12 @@ import warnings import sys try: - from setuptools import setup + from setuptools import setup, Command setuptools_available = True except ImportError: - from distutils.core import setup + from distutils.core import setup, Command setuptools_available = False +from distutils.spawn import spawn try: # This will create an exe that needs Microsoft Visual C++ 2008 @@ -20,25 +21,37 @@ try: import py2exe except ImportError: if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe': - print("Cannot import py2exe", file=sys.stderr) + print('Cannot import py2exe', file=sys.stderr) exit(1) py2exe_options = { - "bundle_files": 1, - "compressed": 1, - "optimize": 2, - "dist_dir": '.', - "dll_excludes": ['w9xpopen.exe', 'crypt32.dll'], + 'bundle_files': 1, + 'compressed': 1, + 'optimize': 2, + 'dist_dir': '.', + 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'], } +# Get the version from youtube_dl/version.py without importing the package +exec(compile(open('youtube_dl/version.py').read(), + 'youtube_dl/version.py', 'exec')) + +DESCRIPTION = 'YouTube video downloader' +LONG_DESCRIPTION = 'Command-line program to download videos from YouTube.com and other video sites' + py2exe_console = [{ - "script": "./youtube_dl/__main__.py", - "dest_base": "youtube-dl", + 'script': './youtube_dl/__main__.py', + 'dest_base': 'youtube-dl', + 'version': __version__, + 'description': DESCRIPTION, + 'comments': LONG_DESCRIPTION, + 'product_name': 'youtube-dl', + 'product_version': __version__, }] py2exe_params = { 'console': py2exe_console, - 'options': {"py2exe": py2exe_options}, + 'options': {'py2exe': py2exe_options}, 'zipfile': None } @@ -70,16 +83,27 @@ else: else: params['scripts'] = ['bin/youtube-dl'] -# Get the version from youtube_dl/version.py without importing the package -exec(compile(open('youtube_dl/version.py').read(), - 'youtube_dl/version.py', 'exec')) +class build_lazy_extractors(Command): + description = 'Build the extractor lazy loading module' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + spawn( + [sys.executable, 'devscripts/make_lazy_extractors.py', 'youtube_dl/extractor/lazy_extractors.py'], + dry_run=self.dry_run, + ) setup( name='youtube_dl', version=__version__, - description='YouTube video downloader', - long_description='Small command-line program to download videos from' - ' YouTube.com and other video sites.', + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, url='https://github.com/rg3/youtube-dl', author='Ricardo Garcia', author_email='ytdl@yt-dl.org', @@ -95,17 +119,19 @@ setup( # test_requires = ['nosetest'], classifiers=[ - "Topic :: Multimedia :: Video", - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "License :: Public Domain", - "Programming Language :: Python :: 2.6", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.2", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", + 'Topic :: Multimedia :: Video', + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'License :: Public Domain', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', ], + cmdclass={'build_lazy_extractors': build_lazy_extractors}, **params ) diff --git a/test/helper.py b/test/helper.py index bdd7acc..dfee217 100644 --- a/test/helper.py +++ b/test/helper.py @@ -11,8 +11,11 @@ import sys import youtube_dl.extractor from youtube_dl import YoutubeDL -from youtube_dl.utils import ( +from youtube_dl.compat import ( + compat_os_name, compat_str, +) +from youtube_dl.utils import ( preferredencoding, write_string, ) @@ -21,8 +24,13 @@ from youtube_dl.utils import ( def get_params(override=None): PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "parameters.json") + LOCAL_PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), + "local_parameters.json") with io.open(PARAMETERS_FILE, encoding='utf-8') as pf: parameters = json.load(pf) + if os.path.exists(LOCAL_PARAMETERS_FILE): + with io.open(LOCAL_PARAMETERS_FILE, encoding='utf-8') as pf: + parameters.update(json.load(pf)) if override: parameters.update(override) return parameters @@ -42,7 +50,7 @@ def report_warning(message): Print the message to stderr, it will be prefixed with 'WARNING:' If stderr is a tty file the 'WARNING:' will be colored ''' - if sys.stderr.isatty() and os.name != 'nt': + if sys.stderr.isatty() and compat_os_name != 'nt': _msg_header = '\033[0;33mWARNING:\033[0m' else: _msg_header = 'WARNING:' @@ -140,6 +148,9 @@ def expect_value(self, got, expected, field): expect_value(self, item_got, item_expected, field) else: if isinstance(expected, compat_str) and expected.startswith('md5:'): + self.assertTrue( + isinstance(got, compat_str), + 'Expected field %s to be a unicode object, but got value %r of type %r' % (field, got, type(got))) got = 'md5:' + md5(got) elif isinstance(expected, compat_str) and expected.startswith('mincount:'): self.assertTrue( diff --git a/test/swftests/ArrayAccess.swf b/test/swftests/ArrayAccess.swf deleted file mode 100644 index 6cb49aba8fb0b7be32dcbc5fea25069def5ee871..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 609 zcmV-n0-pUtS5ppl0{{Sc+Fg;&Zqq;%h3|OAc3LDzRRjfuWS~+uP3)vqr9`PkAOzSH zsccYJ9oyr?)PJ(aBwfLV2SGx-1`hy>BuKD^1>zl8lo_`)0n2~)%(BsOGCouuG9A*qcHZgXL-lD&B zpIM~YTLiV2ev``XhMPoYnk8Q0icG#hmCeg75|I{87~~_C*+qODC*!kEEL7=nGe&vx zuj8*K*Fzc)3p!->qy2L2qAoL1&g=nmjONak(XyJmXECJOHUFFTxgs{uhJN)I?!rUm z^z`&_6^k9##6`4shfp5L@1Nff#EySn?PVD~>A5b;bNG0*Ei`e0pV5dlp$ZM@UIn$Z zY5PUwud^f=5IMd}V4eI3m^&c>%XaSjg3NIlAS6-WT;B2ru;P?$shx diff --git a/test/swftests/ClassCall.swf b/test/swftests/ClassCall.swf deleted file mode 100644 index 849cca4f687307bc68c80948f9f4ea94ab6b5c53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 581 zcmV-L0=oS}S5ppl0{{Sc+Fg;&Zqq;%h41{>CRtRiQlV6+k|iQ#Lt;CvkP;;pRYLe# zP^l|a3DJo?NlYEvvd1K>;8Dtk*I*Bu6p06b4ZKAdJ8hgYvSpupzjJ&&vjF-VVCM@! z6~SQd002H#z9WEc?2bEUgQ32d`9ac=s#l*15p@h>KA$(|N6j#v7*@O8Hq4gMYBeO$ zNInFDEgC`cux{r81D-gs7YQ#6^h~o+n2KJ#ev|4to6snY{XEij4DRz84@6>EO-ly3 zPG=m(GbU^nMZV{-EY4Uol4+`MhcBBFHUd&!i?b{bp;;e7pxqM9*I%$W%9 z61TOi@3UZ%vI)1JzRG(WozKVww}*VBTgQ*|mT5g+kC9co#(%qgQ;`Q~!(jI>=|Uf` zR;%+ekteLmo2sABAzyEmKfli8iGM5i}N;LsWK0_8rc5(TO%Xd1#AA{wF^Q8XmwJuM#! z!DeBEwiIAYN*FLuQlg+B1px)5?h!=f17j*R#Yh8$2qjDNnam=X(8|($Ltj$(M1Nk_ z+}i$7!O!z-s;EnI`2r+J3J;YQrL;7!e_Ykjl_Zrrq$-W%!P4Y#LCg#C8V;xU_8lEg TsYG@v+0@0BK9TAlQirOH|5+_z^0kM5#rU5FQJV zxU)=_X^};>rSDlRVlhiZZaJnSjeM^^ zkp3F3rR<-!5q_RkhNfhP*%iJP4OL)2Z#kyN@yo^!7uQM)s z6&}%KR?r!9pS`ZJ%eu};1#`!2VmJqnjIQlGS;eTj1M9!rKJUl@x-i=Liw7`NmdoYI zHkK3CPXk>SO_+kqTnqB z6d-tu0FfNEff1IQq7VdxC`bc@Fu@D^xkQnI$<2lRj=Uo9nf%;`7t#VDqG}6!@e(8j rui4}pph_Nou&^1NV*3=og}p$z_(ppHk(B0c6>;;pk)Qk!hm;$&c0J3BjuSvTtS zDl)3+aU}V)8l{gac5cuSsgndF8N^XJi+MjD%iT(4?&>-hrlWBZ=9aEwh)@hgBvZqx zS!m=sO)pM{T-tmz3Im5{cE+@t`mu8~;U7fR3wi3dj0G{%$Uug|Zo6?`l)IsrmK){v zLZ7qGC>hyZ6l!0(CePG0CmtH3BzDIR*5sj8F1{?uEJovg7^J>P>~VAy#gnrm7HGzC z62WEsFXJ4`@*$4~V?Ge}(^q-!BF<~%QrKP5FI$bxa^1AH&&tTqmT{%qa|8!yLucg= zYr!5pJv}`rF`Tf5ThTrrK)$}N|Ngm;6F({K#ZfBTNy3lYjw8|(zTJF@3H-oI_)u7| z0yUr%9}KV{k}FpQ+Ux#%;Yi|WnC=M)f6~P@OQHC^}Jfrs+)ANkJ#Y`=q!`)citZ zzRwq-tVjV32;fiE2q8>EFDR@sf+)p=ig~82&CEk}gZk>BwprR-dP{xn8S2qMS)Q4* zC-8~>IO!_z9Iy*m(9+E8X&b~VdL@K1GgU+03qX}Z@t7MkQ$UZIJ@yVB_!Qw=YguXk Nb^0-ae*t!M@(iL`D|G+> diff --git a/test/swftests/ConstantInt.swf b/test/swftests/ConstantInt.swf deleted file mode 100644 index fe9c5c6bdc8c1d4532073e91295236aff408881b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 516 zcmV+f0{i_#S5pr80ssJb+FemWZqq;%{o|R~YLOsSQB@X579eFqVmnlo5~UVZL!cXw zx7-*L{er$$Em8SS3T>AeBpS5!N76*PQTw(if-|N zOImk%@wnqR0b^DKd7Q~ua9d+K6Qw-qbZ%0^;5IZX^Q4Ik1BWFnWn31H*Yi|R7!2nk zPpR~2mL+jOb(~Xoi%1056@AaT^Mn@B$k_0J+=F;cf1}$vm@ufzkS1~1^O^<|HdOYGghnB=cnpnuN5VjDpaLYm_SvP~tK?dG2Kt&qFLF<145)_F5Trhs1jBX-&?v2rr4e0x9~7B6y4s}&9>k4T;V@i GqtS@_H~km@ diff --git a/test/swftests/DictCall.swf b/test/swftests/DictCall.swf deleted file mode 100644 index b0296d04d27a52b876c0d63bec516b2189dd1e01..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 545 zcmV++0^a>YS5pok0{{Sc+Feo0Zqq;%z2lkKNhF|E5fmgOBNo{-89S|t5~UVVLx2rP zWrMov#2zQ6e#stVcg3&3hTmX~*rcBT8{jL-*h%BUNVB--o^$T20P+*y_7{L%1e5It z0Pu0=I|3LbjypV=O!Xr0!*nR4qs~Hzct~lU=e>Nt7bSCQ4h92i^l87}m5gqB5eimx z!}LkVsthJPwG%HEUKHwO%w|z0jyj#St7C6W<1FzjOUI_%=K&8zO3j`rjU0REMoGYg z#p2laY*yOQqMI%v`#fhKc-Qq=x){-#SZahPd~S`MXvX!a&kOxPAJ_Vdy`q$4r*71` zF(xb3Jv$0$oJ3A$%br|mRf%s(N{cv~`Chu^o3I7FlG+07g+hHZd(Umryrz?Y zc_AtuulH8(Z2Weg_6_5Z&N9yzl5^3#hjvK=8gL&qwTDE}FhLDf(KHPy8p0YP8fvsu z)M_G97DPya`XQ{e6p#oa+ZZ8?q#B4MVS<;&3yCWVCheth={7E1_0vlL1tHQZqq;zo%K2~^iWy_p>ja7M5SDa*A7*sM5#p~4RE1S zPpDkFwl}fcwb$5d98P=-7cSiR0X~2O`31PZUxZz!G;LQ}Y39v)Z)SJqVEzW!`~t9p zV7&bh06ukoAb?R3O@}Ari9JtwRt{Bm(2b?chlJF1?bJ^lQOt-p7z~KpC;fg;F?!|4 zOwxHTD<60L#$e3Kut;*5h|JbG4MZgmy4_3HD7-SwtAaO{QAikPDa&L@JjYW;Q8=86 zBBj!&dCrrNYCAITm9YpfYWjiorks}Xh^&cPBNNG)e;A2?*%Qv@_MUyX);H`GMU$iT zp#HUIQmuAEk&?U+Q5CA0rpl@jUzcc$yb5?y#;owG>>?BOs>K@BoUmY2ikpo8n67i0 z%_=%${?VJJc9l0XQpx-Y3v6%iiQRX-{nZ#69g$nVeTk?A`Y_)5i%0OnST2{R8(3|) zt*+VrdhhC3Ox{fzyD2@RRyL6O_>K<;6Nj{o(sVl%{Ff; z+Q-2;3#FOTB*PET4u+P63=3fknHFl9O*;hZgA9Dv07C`lHbw{|!$e?$icGw4UuuF1 z?=0M1v}=5Q1z;d#w%QAK@fuVWs}$c`xD3v)dxqb_qu5Yzr=xq^ddxEg{R8J1)+qV- B`K$l{ diff --git a/test/swftests/LocalVars.swf b/test/swftests/LocalVars.swf deleted file mode 100644 index 02a267f69ff167d50e7228af22102a8d86c16aac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 517 zcmV+g0{ZmG;7K;Km&;Asjfv1^z{_HzixJWXUscX8i0o1M(AK>jS_Z zg2B!$065$If&luNKkgk3hW0E9W7*T_pgC14?NM43MZ37)PO=GgyWK8zI<(ViX+=xE zj}@D>VtJ?Ol>q}Gc^0H9NMhSyHcE1J&}?3&`g|Rl=2=)q`kabTL?Tv_x@}hn`Mfty zvWO{LTiJx=b(^yB9=BpMHk>;Z?kW-O)d3+it#p;TRH5#4?rjmaZe>qbR zSv<+vM0ihLmbEo5dt^#@Lou@5{d;!DaUZPOFl?Xx_uH3@9-s$+IpLA4huPpEqA5oQ1DhCgIcdkGi5s7-uXJE^I>^N+%9twXqh~Uya@h zu1Lg!7~e#D7-|hm&{C`+zBYFRoM7h!zk%CROVeAs=ECYVk2LxN Hdui6OmnZQP diff --git a/test/swftests/MemberAssignment.swf b/test/swftests/MemberAssignment.swf deleted file mode 100644 index 970cfcbc6dc452a1fbb11bd5e8287ad43f042e80..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 558 zcmV+}0@3|LS5pp10{{Sc+GSD8Zqq;%z1K6g+b&9~0xAn6ODwV>aS|$|M5#p}gt7pn zu25H<*yF^lU$Vz_Siz^jhTq@=*d#0vTiC!~gc+x8N*USG+;h)4b7t-g=r4fn&j5P} z!<~Bo@P79z0`xP_?;QwD zE*5Ooi1P<^r!pAw+|7bi1W9bEnvIh}9MtO7YV<(X5&XK_-lj##6L<7S+R%4DFD?0>V(zia-l{xHK2s5 zo{pdy2n5jFA&5F^6y+Td2_^H^i;7L?_PjNJ3LmuZ-xebS4*@hpsv8pZsjP^mQT>*z w7K}<{KGNZ%gy|*eB}gM(YKSCpI3cYQ@)qt-H3{F@RoVV~ohK6f3z6#N&Hhjn5&!@I diff --git a/test/swftests/NeOperator.swf b/test/swftests/NeOperator.swf deleted file mode 100644 index f882b5f2e92cc99088729edb351632dc1a67e267..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 535 zcmV+y0_goiS5pok0{{Sc+Feo0Zqq;%z2liAY8EtAB2*SgmWULoA{jeWNQqL5sv*Fp zm9j!zbz)Bvw|>bUW3%E{V8d_l0o|mFegH@a{vymcB@T>a>7H}XIdjK12l4~p(N};& z1mlAz0Pv}KivUKkGapXJ6Fv96AQ?(@(pd@-4JpmCte3s$h4F%#gTa6recJDLrJ|dB z3e$=RD2=@$(y=M`xX%NTP_t*sAjclg z!`NrSVo~I|HdApl?wO{qJu-Fmizwj2pl42+p+idVN{P za>G^mk?NOAC{8~8^?fQgep^517ZH!uFz~JQQ??`v^O*VEga-7Wuwpk5JIdESVFwNGB{je Z;|jlrr%O%J`%N|8&f8x}_y;g5;X_ZG0~`PV diff --git a/test/swftests/PrivateCall.swf b/test/swftests/PrivateCall.swf deleted file mode 100644 index abc66d66db046fa64c8bceb796969ff52d98ff17..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 595 zcmV-Z0<8T*S5pp?0{{Sc+Fg;&Zqq;z$7j83y9pAsDndn7B}-Jwg~WEKkQ${HRYUkV zP}BoLMM!Mybz|z-mc4Gm33wDPyao>dhj8El-~w+^X59~`UD>kdKfn2V#xn!<2jJ#c zfHeYxmAe4&arHX^=;uM$I~WYD*(6Si9!5K@v6NZQwx`o+XZoO%=0~=>y}fNaUAx%fPoqEG8n6h3$4+ zGz$D)nC25MJ)UK8Yn{9JIE zUL`Ixm5+IHRPrO?J$_N;F5{|4E`>J~Bg@^oZ*?8_;aM9>?c3M>_PK%!^kA_3kM?0t zJ3T!;Y*O5?fj2Y0971(Izxn(705|@l`7)1A&~1;$F?_rI3N^eS%=tvPunZkVH-Scp zys>~9`=j^5m(6{NQ|{p=iuHwThZmb}ug+;%$ig!5*@Q=lafhr?9o7sTV96w!NvKJf zNp({3bHB_>{*Yx16qn zLB7`yl5EO^%hEIoJtpIj5Cqk zCayGj9jCQcLXfd3cVGp&(s2jW zFc$P2xqC|-Wh9)nLQW0Gb9- z45Au@8bmWx-Ow5aL9x}S+9psx%H_JQRoYZg(P)!`uIL0X12iCwRh6hf3j{+8YhNXup1r4A^SE!Z<>xrqAv9Yd}n`9aJ7Hwwl};$c%Ie>9;Hf mCa4eRHiu(sAJY%8IZ?0nWOJe+vc4uSv^;_5sQm}EZ}wu!OCd!7 diff --git a/test/swftests/StaticAssignment.swf b/test/swftests/StaticAssignment.swf deleted file mode 100644 index 2b8bf88700bac8a495f968b929d375178091f728..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 516 zcmV+f0{i_#S5poI0{{Sc+GUZ!Zqq;zhG)GSTjT(#3aA{AEOE$%WbL#pGlx7B0L6;sLm%j{p~Vi?HjIrj(U@n18Q;wcnJ=i{@As+KqrF~76P@Ct zP;Au^#iMpm2aI_U=5eNCDO^*tnJm?DyM37&g;$|jnJ0B*6jGk>lnYf*zw7IuC>+dX zo-!4%EKA~$nK-)Y6iXSNRqUL1<_Rm7L%IWvN5v}P!6=e5?oJZEa*y26&R^48#K6&R z(BRrLnQ?bRnbItmQ5ou)<~pi2U$>ZutehorvE+GBiZdar?G-!KFk#M_lK&EaHPcU+ zSd?tRgXgd7-c?=C$P^DIeCGN`kKLZa@Nj8q`QE;{>c5vg)#4v$ G?AV}3Qvi|x diff --git a/test/swftests/StaticConstArrayAccess.swf b/test/swftests/StaticConstArrayAccess.swf deleted file mode 100644 index 4eec38080d59e9a71c600d45e1bfc263bb8c8c7a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 575 zcmV-F0>J%4S5pp`0{{Sc+I5jXZ__{+#^3XuZIS`CDyo923QJUEA+a60BuXu!hCr8A zf(3Qz<$OupI=1DzH0gx+C@g#pX2g<>6*2KG!kyFBEh?5Ry?=hs8$ree}{OHgZMBx4@*!gR=;LChDizJ<|e^FL7!*Wh#dY`zd z>3&R;@r;gn@aDMa-R8xNRPx|By>$HcOQ+@e`|B}uwd?+K+t(GfzySIie{dHLjn!&( zTE%L^mimbGDeA>iASzG|x%Mme2wA2y(= zg%!Y2BDWt_StrAD&SdpOsYeCJ0S|$+0t|V N=bB%u)?ZyT_|fIE9`*nL diff --git a/test/swftests/StaticRetrieval.swf b/test/swftests/StaticRetrieval.swf deleted file mode 100644 index 0823df4acfe1eaa3308850a66d366644593da5af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 516 zcmV+f0{i_#S5poI0{{Sc+Feo2Zqq;zp7lDm=%GKfLgj#DiAuTPtQ{((M5#qZ2;~A& zxS*c0S#J`z{*%3q-BX{13$M`!;Nn++3%o_xbxKpR(n>queBU=SI~C}^0Cv9v93vPW zJO_Z=!ygD>komLzcsR1ED2(&IjLzB%A<{k}Wm$I0*PSGr6Svpv5vNPKU0X8j{3aH( zvg7<^+iMJlJZD*uiXe$C71L=_h_iP4-qmLhrfHFdjit{B4|&96krTJ$N+X~3XGs=O z;n6e=14fk{sqB1_u@`J^{Y|6Z zqcN#ccUTgUG)w$~$)0A?su4eyD2ue1hC#mInODTuaZ;{JY*58v8K)xopYab<`H;r* zg3h`3{!^2Ch?^d%;NFN&E%)@5)pguA>oycRAX~qEkH`gjFx>xx2k=f?tyY&iSZ>&m zS2w<0LUZiu_s_B1c)jyQ$gg2zF0z0xX$W^mcQP+iFw1DfUD$_?QkZ~)SnO@ljnC67 z&IDTO5e;Je3>{-IOr)6zn@BfN%S49WR79{jNW)Jw&;T?Y5Q5eLMhGKKN1$S?9N+{lPSAyvAf&g9+NnQ+hvS5pr90ssJb+Fg;)Zqq;z#%H~bO)CVAicmQqS>ljO6WgIeN|ag@LVycM z<$`+ZdcFSB+H1>R<8VSe3Kx#N00$lbA%z1E02g?Ru|^I9DCdKaz%y)-TAGHopbYO|DOjEl;42d*>< z=s3*Fj0leuMVe5e?Cg2JigSA2kT%cl%*SGWv zQE;#x)Z2I_QPl&QXLeEMK~3dMp|om?H%pX7QTu69#jNyde$Mk|)nctGhL((o{3`KJ zQ~8wes3sBfp1f#tmvK8I5zL!0-*ON3t)b&SSdF37iT&T-zEI=>J(%wN!4r6_Etkua zZ7erz$WJ#uoIra%z5o65SZ@5=_A5~)JbFZ`gjVq7)@PZNI)o+3mvUD#;DLUl5k9XYNU)uBF4AT9tOiinu)N9bQ5(=7aai#I`~79+n+AQ$Hv?r?5rptNUBP7rBc7D{3k|{B|-7e8Pq|<2$ zMk{?Aayn~;>BFX38jM(KCtl3GDAbCYT2aPNo6WVWV{c63Eb&WA$0p2Y0SkFbjJ6?+ z9J@D(l7MoP#VIGEIb4DZVZ#EaJ@az0_rinT1zjl&_ws(1K$pjPmGT z#$T-H`!t+pbjr-f&&%GXE;CZj%rUbxeP=*Gz^MuGOpjcKnDu|N|>jbFGALut8O zUevMJup&NL`FH{4dG-G1_cO8aMg5#7UN{}PG#N$?8*uot_gfG|4<-o>m;nuF7m{tj zUdS6a`N|9HHM6-KP%p&PvLCD`Sxs?pendLDenPCw^SKw+?TuKzi}vxB3W|y(6=4<0 zDype?OD;nqs1B0wwgi&6$U7Jzj3gO>4B{r^x&EXeNLb#R>xas>#Q_@E(1G)5F|NUf urvMT{a!r}*^JgHKSd{qoTxW2J^-KH`?z@tJ@9Y-u{Wp$B0{jCaqU!eU@fa5X diff --git a/test/swftests/StringConversion.swf b/test/swftests/StringConversion.swf deleted file mode 100644 index 8c88556ed7b359d2d0f5898bf59930aed4cfe996..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 532 zcmV+v0_*)lS5poW0{{Sc+GUZ!ZqqOr$3Mqz!ghd812hgukwEH&Hc6R~T6GcAN`VVV zoS;~nMkH77&t6t8RN2ayq>3m z!eAKXBBRo$MUf@})p5?eTgG{CQqxn`jZ#|1BWDe2k4$9B{QWSWGJBG;xxH)eul)_Z zLNpw%2lcO9lWKP_$TO!9c~}K%rbtCK=BpMRQB>13DPt!5il6YjULCPkH4_L%W&SVm zSJVBJ@>xY^%zyT(>0Q>%j8rmz!lt&j`^fIQ-jmfBS{*sp{`Q5U9?*wz`!^oJfw5dJ zk2bM-VN-p?{Bi`%+W7qI$Dw-h^UXI>Bz$&|^HU~D6$0OGpD94~AQCiV9<-sSEjIus zT(+UOVE19lynS4GlB2F&3JPq~n#}W(rkQYrbjG5qULB;xgieUx^Em)vFe3RBKqlsm%UY{KGV# zP%*FQocqsCTkg7UXQYz*r`e_LJwC7pu6MW^L!)Eo*5AHD)B=5&Z2!h%cxo({%d<_a zHf*Yom>MJ(piN-!N!!neJzidPhb1x>jJ+tAmJJAh*$w{FSJ zm$SE=Ns`i7U^-)F!o^%h_#WEFU|Ptq5VjDpP{%?RXbetV^!j<#^rF1-E;f~9z=$M_jYxY+b?^f Ju)i<3+#w(A{2c%Q diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py index 938466a..6404ac8 100644 --- a/test/test_InfoExtractor.py +++ b/test/test_InfoExtractor.py @@ -11,6 +11,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import FakeYDL from youtube_dl.extractor.common import InfoExtractor from youtube_dl.extractor import YoutubeIE, get_info_extractor +from youtube_dl.utils import encode_data_uri, strip_jsonp, ExtractorError class TestIE(InfoExtractor): @@ -66,5 +67,14 @@ class TestInfoExtractor(unittest.TestCase): self.assertEqual(ie._html_search_meta('e', html), '5') self.assertEqual(ie._html_search_meta('f', html), '6') + def test_download_json(self): + uri = encode_data_uri(b'{"foo": "blah"}', 'application/json') + self.assertEqual(self.ie._download_json(uri, None), {'foo': 'blah'}) + uri = encode_data_uri(b'callback({"foo": "blah"})', 'application/javascript') + self.assertEqual(self.ie._download_json(uri, None, transform_source=strip_jsonp), {'foo': 'blah'}) + uri = encode_data_uri(b'{"foo": invalid}', 'application/json') + self.assertRaises(ExtractorError, self.ie._download_json, uri, None) + self.assertEqual(self.ie._download_json(uri, None, fatal=False), None) + if __name__ == '__main__': unittest.main() diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index 59f7ab4..ca25025 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -222,6 +222,11 @@ class TestFormatSelection(unittest.TestCase): downloaded = ydl.downloaded_info_dicts[0] self.assertEqual(downloaded['format_id'], 'dash-video-low') + ydl = YDL({'format': 'bestvideo[format_id^=dash][format_id$=low]'}) + ydl.process_ie_result(info_dict.copy()) + downloaded = ydl.downloaded_info_dicts[0] + self.assertEqual(downloaded['format_id'], 'dash-video-low') + formats = [ {'format_id': 'vid-vcodec-dot', 'ext': 'mp4', 'preference': 1, 'vcodec': 'avc1.123456', 'acodec': 'none', 'url': TEST_URL}, ] @@ -502,6 +507,9 @@ class TestYoutubeDL(unittest.TestCase): assertRegexpMatches(self, ydl._format_note({ 'vbr': 10, }), '^\s*10k$') + assertRegexpMatches(self, ydl._format_note({ + 'fps': 30, + }), '^30fps$') def test_postprocessors(self): filename = 'post-processor-testfile.mp4' diff --git a/test/test_compat.py b/test/test_compat.py index b6bfad0..f5317ac 100644 --- a/test/test_compat.py +++ b/test/test_compat.py @@ -10,34 +10,39 @@ import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from youtube_dl.utils import get_filesystem_encoding from youtube_dl.compat import ( compat_getenv, + compat_setenv, compat_etree_fromstring, compat_expanduser, compat_shlex_split, compat_str, + compat_struct_unpack, compat_urllib_parse_unquote, compat_urllib_parse_unquote_plus, + compat_urllib_parse_urlencode, ) class TestCompat(unittest.TestCase): def test_compat_getenv(self): test_str = 'тест' - os.environ['YOUTUBE-DL-TEST'] = ( - test_str if sys.version_info >= (3, 0) - else test_str.encode(get_filesystem_encoding())) + compat_setenv('YOUTUBE-DL-TEST', test_str) self.assertEqual(compat_getenv('YOUTUBE-DL-TEST'), test_str) + def test_compat_setenv(self): + test_var = 'YOUTUBE-DL-TEST' + test_str = 'тест' + compat_setenv(test_var, test_str) + compat_getenv(test_var) + self.assertEqual(compat_getenv(test_var), test_str) + def test_compat_expanduser(self): old_home = os.environ.get('HOME') test_str = 'C:\Documents and Settings\тест\Application Data' - os.environ['HOME'] = ( - test_str if sys.version_info >= (3, 0) - else test_str.encode(get_filesystem_encoding())) + compat_setenv('HOME', test_str) self.assertEqual(compat_expanduser('~'), test_str) - os.environ['HOME'] = old_home + compat_setenv('HOME', old_home or '') def test_all_present(self): import youtube_dl.compat @@ -70,6 +75,16 @@ class TestCompat(unittest.TestCase): self.assertEqual(compat_urllib_parse_unquote_plus('abc%20def'), 'abc def') self.assertEqual(compat_urllib_parse_unquote_plus('%7e/abc+def'), '~/abc def') + def test_compat_urllib_parse_urlencode(self): + self.assertEqual(compat_urllib_parse_urlencode({'abc': 'def'}), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode({'abc': b'def'}), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode({b'abc': 'def'}), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode({b'abc': b'def'}), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode([('abc', 'def')]), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode([('abc', b'def')]), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode([(b'abc', 'def')]), 'abc=def') + self.assertEqual(compat_urllib_parse_urlencode([(b'abc', b'def')]), 'abc=def') + def test_compat_shlex_split(self): self.assertEqual(compat_shlex_split('-option "one two"'), ['-option', 'one two']) @@ -88,5 +103,15 @@ class TestCompat(unittest.TestCase): self.assertTrue(isinstance(doc.find('chinese').text, compat_str)) self.assertTrue(isinstance(doc.find('foo/bar').text, compat_str)) + def test_compat_etree_fromstring_doctype(self): + xml = ''' + +''' + compat_etree_fromstring(xml) + + def test_struct_unpack(self): + self.assertEqual(compat_struct_unpack('!B', b'\x00'), (0,)) + + if __name__ == '__main__': unittest.main() diff --git a/test/test_http.py b/test/test_http.py index f2e305b..5076ced 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# coding: utf-8 from __future__ import unicode_literals # Allow direct execution @@ -15,6 +16,15 @@ import threading TEST_DIR = os.path.dirname(os.path.abspath(__file__)) +def http_server_port(httpd): + if os.name == 'java' and isinstance(httpd.socket, ssl.SSLSocket): + # In Jython SSLSocket is not a subclass of socket.socket + sock = httpd.socket.sock + else: + sock = httpd.socket + return sock.getsockname()[1] + + class HTTPTestRequestHandler(compat_http_server.BaseHTTPRequestHandler): def log_message(self, format, *args): pass @@ -30,6 +40,22 @@ class HTTPTestRequestHandler(compat_http_server.BaseHTTPRequestHandler): self.send_header('Content-Type', 'video/mp4') self.end_headers() self.wfile.write(b'\x00\x00\x00\x00\x20\x66\x74[video]') + elif self.path == '/302': + if sys.version_info[0] == 3: + # XXX: Python 3 http server does not allow non-ASCII header values + self.send_response(404) + self.end_headers() + return + + new_url = 'http://localhost:%d/中文.html' % http_server_port(self.server) + self.send_response(302) + self.send_header(b'Location', new_url.encode('utf-8')) + self.end_headers() + elif self.path == '/%E4%B8%AD%E6%96%87.html': + self.send_response(200) + self.send_header('Content-Type', 'text/html; charset=utf-8') + self.end_headers() + self.wfile.write(b'