Merge pull request #258 from billd100/master
Browse filesUnavailable videos throw VideoUnavailable exception.
- pytube/__main__.py +3 -0
- pytube/exceptions.py +4 -0
pytube/__main__.py
CHANGED
@@ -21,6 +21,7 @@ from pytube import Stream
|
|
21 |
from pytube import StreamQuery
|
22 |
from pytube.compat import install_proxy
|
23 |
from pytube.compat import parse_qsl
|
|
|
24 |
from pytube.helpers import apply_mixin
|
25 |
|
26 |
logger = logging.getLogger(__name__)
|
@@ -156,6 +157,8 @@ class YouTube(object):
|
|
156 |
|
157 |
"""
|
158 |
self.watch_html = request.get(url=self.watch_url)
|
|
|
|
|
159 |
self.embed_html = request.get(url=self.embed_url)
|
160 |
self.age_restricted = extract.is_age_restricted(self.watch_html)
|
161 |
self.vid_info_url = extract.video_info_url(
|
|
|
21 |
from pytube import StreamQuery
|
22 |
from pytube.compat import install_proxy
|
23 |
from pytube.compat import parse_qsl
|
24 |
+
from pytube.exceptions import VideoUnavailable
|
25 |
from pytube.helpers import apply_mixin
|
26 |
|
27 |
logger = logging.getLogger(__name__)
|
|
|
157 |
|
158 |
"""
|
159 |
self.watch_html = request.get(url=self.watch_url)
|
160 |
+
if '<img class="icon meh" src="/yts/img' not in self.watch_html:
|
161 |
+
raise VideoUnavailable('This video is unavailable.')
|
162 |
self.embed_html = request.get(url=self.embed_url)
|
163 |
self.age_restricted = extract.is_age_restricted(self.watch_html)
|
164 |
self.vid_info_url = extract.video_info_url(
|
pytube/exceptions.py
CHANGED
@@ -34,3 +34,7 @@ class ExtractError(PytubeError):
|
|
34 |
|
35 |
class RegexMatchError(ExtractError):
|
36 |
"""Regex pattern did not return any matches."""
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
class RegexMatchError(ExtractError):
|
36 |
"""Regex pattern did not return any matches."""
|
37 |
+
|
38 |
+
|
39 |
+
class VideoUnavailable(PytubeError):
|
40 |
+
"""Video is unavailable."""
|