nficano commited on
Commit
13d4d83
·
2 Parent(s): d3cad85 66ad357

Merge branch 'master' of github.com:nficano/pytube

Browse files

* 'master' of github.com:nficano/pytube:
Update playlist.py
Update playlist.py
fix total videos found string
Update docstring.
Update exception message.
Catch unavailable videos.

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/contrib/playlist.py CHANGED
@@ -110,7 +110,7 @@ class Playlist(object):
110
  """
111
 
112
  self.populate_video_urls()
113
- logger.debug('total videos found: ', len(self.video_urls))
114
  logger.debug('starting download')
115
 
116
  prefix_gen = self._path_num_prefix_generator(reverse_numbering)
 
110
  """
111
 
112
  self.populate_video_urls()
113
+ logger.debug('total videos found: %d', len(self.video_urls))
114
  logger.debug('starting download')
115
 
116
  prefix_gen = self._path_num_prefix_generator(reverse_numbering)
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."""