Skip to content

Commit

Permalink
Fix SSL Handshake Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mddepew committed Oct 8, 2018
1 parent 005d076 commit 486137a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
15 changes: 12 additions & 3 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import urllib2
import ssl

PREFIX = '/video/pbskids'
NAME = 'PBS Kids'
ART = 'art-default.jpg'
Expand All @@ -20,7 +23,10 @@ def Start():
def MainMenu():

oc = ObjectContainer()
json_obj = JSON.ObjectFromURL(PBSKIDS_SHOWS)
req = urllib2.Request(PBSKIDS_SHOWS)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
show_data = urllib2.urlopen(req, context=ssl_context).read()
json_obj = JSON.ObjectFromString(show_data)

for item in json_obj['items']:
title = item['title']
Expand Down Expand Up @@ -70,8 +76,11 @@ def VideoPage(type, title, slug, start=0):

oc = ObjectContainer(title2=title)
end = start+OFFSET

json_obj = JSON.ObjectFromURL(VIDEO_LIST % (start, end, String.Quote(slug, usePlus=True), type), cacheTime=CACHE_1DAY)

req = urllib2.Request(VIDEO_LIST % (start, end, String.Quote(slug, usePlus=True), type))
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
video_list = urllib2.urlopen(req, context=ssl_context).read()
json_obj = JSON.ObjectFromString(video_list)

for item in json_obj['items']:

Expand Down
16 changes: 13 additions & 3 deletions Contents/Services/URL/PBS Kids/ServiceCode.pys
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import urllib2
import ssl

JSON_URL = 'http://pbskids.org/pbsk/video/api/getVideos/?guid='

####################################################################################################
Expand Down Expand Up @@ -69,14 +72,21 @@ def PlayVideo(url):
break
try: redirect_url = vid_profiles[selected_profile]
except: redirect_url = details['videos'][0]['url']
m3u8_url = JSON.ObjectFromURL(redirect_url + '?format=json')['url']
req = urllib2.Request(redirect_url + '?format=json')
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
data = urllib2.urlopen(req, context=ssl_context).read()
json = JSON.ObjectFromString(data)
m3u8_url = json['url']
# Force http for m3u8, https crashing
m3u8_url = m3u8_url.replace('https:','http:')
# m3u8_url = m3u8_url.replace('https:','http:')
return IndirectResponse(VideoClipObject, key=HTTPLiveStreamURL(url=m3u8_url))

####################################################################################################
def GetJSON(url):

video_id = url.split('guid=')[1]
json = JSON.ObjectFromURL(JSON_URL + video_id)
req = urllib2.Request(JSON_URL + video_id)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
data = urllib2.urlopen(req, context=ssl_context).read()
json = JSON.ObjectFromString(data)
return json['items'][0]

0 comments on commit 486137a

Please sign in to comment.