Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
np1 committed Aug 26, 2014
2 parents 75f2494 + f647fa1 commit d8d81c8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dev/
.test
*.pyc
.pypi
vi.py
__pycache__
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
27 August 2014
Version 0.3.62

[Feature] - Added url_https property to return https url

-------------------------------------------------------------------------------
15 August 2014
Version 0.3.60

Expand Down
4 changes: 2 additions & 2 deletions docs-sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '0.3.60'
version = '0.3.62'
# The full version, including alpha/beta/rc tags.
release = '0.3.60'
release = '0.3.62'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 5 additions & 1 deletion docs-sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,12 @@ Stream Attributes

The direct access URL of the stream. This can be used to stream the media
in mplayer or vlc, or for downloading with wget or curl. To download
directly, use the :func:`Stream.download` method
directly, use the :func:`Stream.download` method.

.. attribute:: Stream.url_https

The direct access HTTPS URL of the stream.

.. attribute:: Stream.bitrate

The bitrate of the stream - if it is an audio stream, otherwise None,
Expand Down
23 changes: 13 additions & 10 deletions pafy/pafy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from __future__ import unicode_literals

__version__ = "0.3.60"
__version__ = "0.3.62"
__author__ = "nagev"
__license__ = "GPLv3"

Expand Down Expand Up @@ -182,18 +182,16 @@ class g(object):
'video_id=%s&asv=3&el=detailpage&hl=en_US'),
'playlist': ('http://www.youtube.com/list_ajax?'
'style=json&action_get_list=1&list=%s'),
'age_vidinfo': ('https://www.youtube.com/get_video_info?video_id=%s&'
'el=player_embedded&gl=US&hl=en&eurl=https://youtube.'
'googleapis.com/v/%s&asv=3&sts=1588')
'age_vidinfo': ('http://www.youtube.com/get_video_info?video_id=%s&'
'eurl=https://youtube.googleapis.com/v/%s&sts=1588')
}
ua = ("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64;"
" Trident/5.0)")
user_agent = "pafy " + __version__
UEFSM = 'url_encoded_fmt_stream_map'
AF = 'adaptive_fmts'
jsplayer = r';\s*ytplayer\.config\s*=\s*(\s*{.*?}\s*)\s*;'
lifespan = 60 * 60 * 5 # 5 hours
opener = build_opener()
opener.addheaders = [('User-Agent', ua)]
opener.addheaders = [('User-Agent', user_agent)]
itags = {
'5': ('320x240', 'flv', "normal", ''),
'17': ('176x144', '3gp', "normal", ''),
Expand Down Expand Up @@ -608,8 +606,8 @@ def __init__(self, sm, parent):
self._threed = 'stereo3d' in sm and sm['stereo3d'] == '1'
self._resolution = g.itags[self.itag][0]
self._dimensions = tuple(self.resolution.split("-")[0].split("x"))
self._dimensions = tuple(map(lambda x: int(x) if x.isdigit() else x,
self.dimensions))
self._dimensions = tuple([int(x) if x.isdigit() else x for x in
self._dimensions])
self._vidformat = sm['type'].split(';')[0] # undocumented
self._quality = self.resolution
self._extension = g.itags[self.itag][1]
Expand Down Expand Up @@ -765,6 +763,11 @@ def url(self):

return self._url

@property
def url_https(self):
""" Return https url. """
return self.url.replace("http://", "https://")

def __repr__(self):
""" Return string representation. """
out = "%s:%s@%s" % (self.mediatype, self.extension, self.quality)
Expand Down Expand Up @@ -838,7 +841,7 @@ def download(self, filepath="", quiet=False, callback=lambda *x: None,
if offset:
# partial file exists, resume download
resuming_opener = build_opener()
resuming_opener.addheaders = [('User-Agent', g.ua),
resuming_opener.addheaders = [('User-Agent', g.user_agent),
("Range", "bytes=%s-" % offset)]
response = resuming_opener.open(self.url)
bytesdone = offset
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
name='Pafy',
packages=['pafy'],
scripts=['scripts/ytdl'],
version='0.3.60',
version='0.3.62',
description="Retrieve YouTube content and metadata",
keywords=["Pafy", "API", "YouTube", "youtube", "download", "video"],
author="nagev",
Expand Down
2 changes: 1 addition & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def runOnce(self):
# get urls for age restricted vids
if video['pafy'].videoid == "07FYdnEawAQ":
_ = video['pafy'].streams[0].url
_ = video['pafy'].streams[1].url
_ = video['pafy'].streams[1].url_https
del _

for playlist in Test.playlists:
Expand Down

0 comments on commit d8d81c8

Please sign in to comment.