Make sure netrc works for all extractors with login support
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 3 Mar 2015 11:59:17 +0000 (12:59 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 3 Mar 2015 11:59:17 +0000 (12:59 +0100)
Fixes #5112

test/test_netrc.py [new file with mode: 0644]
youtube_dl/extractor/atresplayer.py
youtube_dl/extractor/crunchyroll.py
youtube_dl/extractor/gdcvault.py
youtube_dl/extractor/lynda.py
youtube_dl/extractor/twitch.py

diff --git a/test/test_netrc.py b/test/test_netrc.py
new file mode 100644 (file)
index 0000000..7cf3a6a
--- /dev/null
@@ -0,0 +1,26 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+import os
+import sys
+import unittest
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+
+from youtube_dl.extractor import (
+    gen_extractors,
+)
+
+
+class TestNetRc(unittest.TestCase):
+    def test_netrc_present(self):
+        for ie in gen_extractors():
+            if not hasattr(ie, '_login'):
+                continue
+            self.assertTrue(
+                hasattr(ie, '_NETRC_MACHINE'),
+                'Extractor %s supports login, but is missing a _NETRC_MACHINE property' % ie.IE_NAME)
+
+
+if __name__ == '__main__':
+    unittest.main()
index 7669e0e3dc643b3bcf8d39663efcf6cba4540b04..29f8795d3dfe2bdae9993f9b1fd3d278cb8c3a9c 100644 (file)
@@ -19,6 +19,7 @@ from ..utils import (
 
 class AtresPlayerIE(InfoExtractor):
     _VALID_URL = r'https?://(?:www\.)?atresplayer\.com/television/[^/]+/[^/]+/[^/]+/(?P<id>.+?)_\d+\.html'
+    _NETRC_MACHINE = 'atresplayer'
     _TESTS = [
         {
             'url': 'http://www.atresplayer.com/television/programas/el-club-de-la-comedia/temporada-4/capitulo-10-especial-solidario-nochebuena_2014122100174.html',
index f1da7d09bc934af86f08aa45f8a1a3de32fa4673..e64b88fbc4f796accae6816c5fcec2f2a1aa3ecd 100644 (file)
@@ -29,6 +29,7 @@ from ..aes import (
 
 class CrunchyrollIE(InfoExtractor):
     _VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.(?:com|fr)/(?:[^/]*/[^/?&]*?|media/\?id=)(?P<video_id>[0-9]+))(?:[/?&]|$)'
+    _NETRC_MACHINE = 'crunchyroll'
     _TESTS = [{
         'url': 'http://www.crunchyroll.com/wanna-be-the-strongest-in-the-world/episode-1-an-idol-wrestler-is-born-645513',
         'info_dict': {
index f7b467b0aff8f46aa028d1898f5909277e973318..51796f3a40310f484cf1a49fc6e11468264dbe3a 100644 (file)
@@ -12,6 +12,7 @@ from ..utils import remove_end
 
 class GDCVaultIE(InfoExtractor):
     _VALID_URL = r'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)/(?P<name>(\w|-)+)'
+    _NETRC_MACHINE = 'gdcvault'
     _TESTS = [
         {
             'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple',
index 1f02bef445b7dc56cc803f7319cb16fef0ece502..cfd3b14f4bfd755a7600701e86900ece12b0c3ac 100644 (file)
@@ -19,6 +19,7 @@ class LyndaBaseIE(InfoExtractor):
     _LOGIN_URL = 'https://www.lynda.com/login/login.aspx'
     _SUCCESSFUL_LOGIN_REGEX = r'isLoggedIn: true'
     _ACCOUNT_CREDENTIALS_HINT = 'Use --username and --password options to provide lynda.com account credentials.'
+    _NETRC_MACHINE = 'lynda'
 
     def _real_initialize(self):
         self._login()
index 4b0ce54df4d329cf24e76621c6064c67a4befaaa..8af1361473ac338d45c0bc0f512953c684b9681b 100644 (file)
@@ -23,6 +23,7 @@ class TwitchBaseIE(InfoExtractor):
     _API_BASE = 'https://api.twitch.tv'
     _USHER_BASE = 'http://usher.twitch.tv'
     _LOGIN_URL = 'https://secure.twitch.tv/user/login'
+    _NETRC_MACHINE = 'twitch'
 
     def _handle_error(self, response):
         if not isinstance(response, dict):