浏览代码

[extractor/common] Add raise_login_required

Sergey M․ 10 年之前
父节点
当前提交
43e7d3c945
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      youtube_dl/extractor/common.py

+ 6 - 0
youtube_dl/extractor/common.py

@@ -510,6 +510,12 @@ class InfoExtractor(object):
         """Report attempt to log in."""
         """Report attempt to log in."""
         self.to_screen('Logging in')
         self.to_screen('Logging in')
 
 
+    @staticmethod
+    def raise_login_required(msg='This video is only available for registered users'):
+        raise ExtractorError(
+            '%s. Use --username and --password or --netrc to provide account credentials.' % msg,
+            expected=True)
+
     # Methods for following #608
     # Methods for following #608
     @staticmethod
     @staticmethod
     def url_result(url, ie=None, video_id=None, video_title=None):
     def url_result(url, ie=None, video_id=None, video_title=None):