Skip to content

Commit

Permalink
Merge pull request #24 from anxdpanic/pr-1
Browse files Browse the repository at this point in the history
resolve age gated, move imports, check for publishedAt
  • Loading branch information
anxdpanic authored Feb 18, 2017
2 parents 657f7be + 59d1d47 commit a31fde0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 2 additions & 4 deletions resources/lib/kodion/simple_requests/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__author__ = 'bromix'

import sys
import ssl
import urllib
import urllib2
from StringIO import StringIO
Expand Down Expand Up @@ -74,16 +76,12 @@ def _request(method, url,

handlers = []

import sys

_verify = __settings.get_bool('simple.requests.ssl.verify', False)
if _verify:
verify = _verify

# starting with python 2.7.9 urllib verifies every https request
if verify is False and sys.version_info >= (2, 7, 9):
import ssl

ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
Expand Down
11 changes: 6 additions & 5 deletions resources/lib/youtube/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,12 @@ def update_video_infos(provider, context, video_id_dict, playlist_item_id_dict=N
video_item.set_plot(description)

# date time
datetime = utils.datetime_parser.parse(snippet['publishedAt'])
video_item.set_year_from_datetime(datetime)
video_item.set_aired_from_datetime(datetime)
video_item.set_premiered_from_datetime(datetime)
video_item.set_date_from_datetime(datetime)
if 'publishedAt' in snippet:
datetime = utils.datetime_parser.parse(snippet['publishedAt'])
video_item.set_year_from_datetime(datetime)
video_item.set_aired_from_datetime(datetime)
video_item.set_premiered_from_datetime(datetime)
video_item.set_date_from_datetime(datetime)

# duration
duration = yt_item.get('contentDetails', {}).get('duration', '')
Expand Down
3 changes: 3 additions & 0 deletions resources/lib/youtube/helper/video_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ def _method_watch(self, video_id, reason=u'', meta_info=None):
'hl': self.language,
'gl': self.region}

if self._access_token:
params['access_token'] = self._access_token

url = 'https://www.youtube.com/watch'

result = requests.get(url, params=params, headers=headers, verify=False, allow_redirects=True)
Expand Down

0 comments on commit a31fde0

Please sign in to comment.