Skip to content

Commit

Permalink
Update Smithsonian Earth
Browse files Browse the repository at this point in the history
Fixed Smithsonian Earth
  • Loading branch information
MetalChris committed Oct 29, 2018
1 parent b9b1e1f commit b3e3145
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 88 deletions.
26 changes: 19 additions & 7 deletions addons.xml
Expand Up @@ -75,7 +75,7 @@
</extension>
</addon>

<addon id="repository.metalchris" name="MetalChris' Repository" version="3.1.3" provider-name="MetalChris">
<addon id="repository.metalchris" name="MetalChris' Repository" version="3.1.5" provider-name="MetalChris">
<extension point="xbmc.addon.repository" name="Official MetalChris Repository">
<info compressed="false">http://raw.github.com/MetalChris/repository.metalchris/master/addons.xml</info>
<checksum>http://raw.github.com/MetalChris/repository.metalchris/master/addons.xml.md5</checksum>
Expand Down Expand Up @@ -974,29 +974,40 @@ ASN televises live games from multiple NCAA Division I college sports conference
</extension>
</addon>

<addon id="plugin.video.smithsonian-earth" name="Smithsonian Earth" version="0.0.4" provider-name="MetalChris">
<addon id="plugin.video.smithsonian-earth" name="Smithsonian Earth" version="2018.10.27" provider-name="MetalChris">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
<import addon="script.module.mechanize" version="0.2.6"/>
<import addon="script.module.html5lib" version="0.999.0"/>
<import addon="script.module.simplejson" version="3.3.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Stream the most captivating nature and wildlife documentaries and videos shot in stunning Ultra HD (4K) on Smithsonian Earth.</summary>
<description lang="en">Smithsonian Earth is a commercial-free streaming site that offers unlimited access to nature and wildlife documentaries and videos shot in stunning 4K UHD resolution. Refreshed weekly, you'll never run out of things to discover.</description>
<disclaimer lang="en"></disclaimer>
<description lang="en">Smithsonian Earth is a commercial-free streaming site that offers unlimited access to nature and wildlife documentaries and videos shot in stunning 4K UHD resolution. Refreshed weekly, you'll never run out of things to discover. Subscription costs $3.99 per month with a 30 day free trial.</description>
<disclaimer lang="en">For support go to my github. No support without a full, unedited debug log. No support at TVAddons or any other forum.</disclaimer>
<language></language>
<platform>all</platform>
<license>GPL(v2) or Later</license>
<broken>Login is broken</broken>
<forum></forum>
<website></website>
<website>https://smithsonianearthtv.com/</website>
<email></email>
<source></source>
<news>v 2018.10.27[CR]- Update for 2018[CR]- Remove quality settings[CR]v 0.0.4[CR]- Fixes for website changes[CR]- Added infolabels[CR]v 0.0.3[CR]- Add quality option in settings[CR]v 0.0.2[CR]- Code cleanup[CR]v 0.0.1[CR]- Initial release</news>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
<screenshot>resources/media/screenshot001.png</screenshot>
<screenshot>resources/media/screenshot002.png</screenshot>
<screenshot>resources/media/screenshot003.png</screenshot>
<screenshot>resources/media/screenshot004.png</screenshot>
<screenshot>resources/media/screenshot005.png</screenshot>
<screenshot>resources/media/screenshot006.png</screenshot>
<screenshot>resources/media/screenshot007.png</screenshot>
<screenshot>resources/media/screenshot008.png</screenshot>
</assets>
</extension>
</addon>

Expand Down Expand Up @@ -1044,6 +1055,7 @@ ASN televises live games from multiple NCAA Division I college sports conference
<summary lang="en">Big South Sports</summary>
<description lang="en">Watch live and on demand events from the Big South Conference, a collegiate athletic conference affiliated with the NCAA's Division I.</description>
<disclaimer lang="en"></disclaimer>
<broken>The Big South website is no longer offering streaming events.</broken>
</extension>
</addon>

Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
@@ -1 +1 @@
4ed91f0ec7910f13f7532e3ec53cf852
b1bd0ff374c7e06c7b7823aab89c8da3
158 changes: 101 additions & 57 deletions plugin.video.smithsonian-earth/addon.py
Expand Up @@ -8,8 +8,7 @@
from bs4 import BeautifulSoup
import mechanize
import html5lib
import simplejson as json
#import Cookie
import json
import cookielib
cookiejar = cookielib.LWPCookieJar()

Expand All @@ -28,7 +27,15 @@
password = settings.getSetting(id="password")
addon = xbmcaddon.Addon(id="plugin.video.smithsonian-earth")
addonname = addon.getAddonInfo('name')
views = settings.getSetting(id="views")
confluence_views = [500,501,503,504,515]
force_views = settings.getSetting(id="force_views")

log_notice = settings.getSetting(id="log_notice")
if log_notice != 'false':
log_level = 2
else:
log_level = 1
xbmc.log('LOG_NOTICE: ' + str(log_notice),level=log_level)

plugin = "Smithsonian Earth"

Expand All @@ -38,12 +45,10 @@
baseurl = 'https://api.smithsonianearthtv.com:8443'

addon_handle = int(sys.argv[1])
confluence_views = [500,501,502,503,504,508,515]


#630
def cats():
#page = br.open('https://api.smithsonianearthtv.com:8443/channels/5DJZN6FN/responsives/categories/16617?5DJZN6FN').read()
page = br.open('https://api.skychnl.net/channels/5DJZN6FN/responsives/categories/48456').read()
cats = BeautifulSoup(page,'html5lib').find_all('option')
for title in cats:
Expand All @@ -53,10 +58,8 @@ def cats():
continue
if '48459' in url:
url = url.split('categories')[0] + 'get_next_category_page?id=48459&index=0'
mode = 635
mode = 636
title = title.text
xbmc.log('TITLE: ' +str(title))
xbmc.log('URL: ' +str(url))
addDir(title, url, mode, defaulticon, defaultfanart)
xbmcplugin.endOfDirectory(addon_handle)

Expand All @@ -70,6 +73,7 @@ def videos(url):
image = 'http:' + (re.compile('image:url\\((.+?)\\)').findall(str(title)))[0]#.replace('.jpg','.background.atv4.jpg')
url = 'https://api.skychnl.net' + (title.get('href'))# + 'token=' + str(cookie.value)
title = title.find('h2').text.encode('utf-8').replace('&amp;','&').strip()
#xbmc.log('TITLE: ' +str(title), level=log_level)
addDir2(title, url, 634, defaultfanart, image, plot='')
#xbmcplugin.setContent(addon_handle, content="videos")
xbmcplugin.endOfDirectory(addon_handle)
Expand All @@ -85,27 +89,42 @@ def series(name,url,iconimage):
br['password'] = password
logged_in = br.submit()
check = logged_in.read()
device_id = re.compile(" device_id = '(.+?)'").findall(str(check))
xbmc.log('DEVICE_ID: ' + str(device_id),level=log_level)
dlsn = settings.getSetting(id="status")
if 'Log In' in check:
xbmcgui.Dialog().notification(plugin, 'Login Failed', defaultimage, 5000, False)
return
else:
if email in check:
if dlsn=='false':
xbmcgui.Dialog().notification(plugin, 'Login Successful', defaultimage, 2500, False)
else:
xbmcgui.Dialog().notification(plugin, 'Login Failed', defaultimage, 50000, False)
return
page = br.open(url).read()
for cookie in cookiejar:
xbmc.log('Cookie Name: ' + str(cookie.name))
xbmc.log('Cookie Value: ' + str(cookie.value))
xbmc.log('Cookie Domain: ' + str(cookie.domain))
xbmc.log('Cookie Name: ' + str(cookie.name), level=log_level)
xbmc.log('Cookie Value: ' + str(cookie.value), level=log_level)
xbmc.log('Cookie Domain: ' + str(cookie.domain), level=log_level)
url = url.replace('https://api.skychnl.net', baseurl) + '&' + cookie.name + '=' + cookie.value
xbmc.log('URL: ' + str(url))
xbmc.log('URL: ' + str(url), level=log_level)
page = br.open(url).read()
#soup = BeautifulSoup(page,'html5lib').find_all('a')
scripts = BeautifulSoup(page,'html5lib').find_all('script',{'type':'text/javascript'})
#for script in scripts:
#print str(len(str(script)))
jsob = re.compile('episodesArray = (.+?);').findall(str(scripts[4]));i=0
jdata = json.loads(jsob[0])
scripts = BeautifulSoup(page,'html5lib').find_all('script',{'type':'text/javascript'});i=0
for script in scripts:
i = i + 1
if 'episodesArray' in str(script):
xbmc.log('### SEASON ###', level=log_level)
count = int(i - 1)
xbmc.log('COUNT: ' + str(i), level=log_level)
if len(str(scripts[count])) > 5000:
jsob = re.compile('episodesArray = (.+?);').findall(str(scripts[count]))
else:
xbmc.log('### SINGLE ###', level=log_level)
count = int(i - 1)
xbmc.log('COUNT: ' + str(i), level=log_level)
jsob = re.compile('new SCVideo\((.+?)\)').findall(str(scripts[count]))
image = BeautifulSoup(page,'html5lib').find('div',{'class':'thumb'})
iconimage = 'https:' + image.find('img')['src']
single(jsob,iconimage)
return
jdata = json.loads(jsob[0]);i=0
for title in jdata:
title = jdata[i]['title']
image = jdata[i]['thumbnail']#.replace('.jpg','.spot.16_9.jpg')
Expand All @@ -118,22 +137,35 @@ def series(name,url,iconimage):
m3u8_url = jdata[i]['vtt'][0]['m3u8_url']
#subs_url = jdata[i]['vtt'][0]['url']
key = m3u8_url.split('/')
q = settings.getSetting(id='quality')
url = 'http://se-media.smithsonianchannel.com/5DJZN6FN/' + key[4] + '/hd/hls/v' + q + '_' + key[4] + '_clear/v' + q + '_' + key[4] + '_clear.m3u8'
url = 'https://se-media.smithsonianchannel.com/5DJZN6FN/' + key[4] + '/hd/hls/' + key[4] + '_clear.m3u8'
li = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image)
#li.setSubtitles(subs_url)
li.setProperty('fanart_image', defaultfanart)
li.setProperty('IsPlayable', 'true')
li.setInfo(type="Video", infoLabels={"Title": title, "Plot": description, "Season": season, "Episode": ep, "Premiered": pubdate, "mpaa": rating})
#li.setProperty('mimetype', 'video/mp4')
li.addStreamInfo('video', { 'duration': duration })
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, totalItems=10)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, totalItems=10, isFolder=False)
xbmcplugin.setContent(addon_handle, 'episodes');i=i+1
if views != 'false':
xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[3])+")")
if force_views != 'false':
xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[int(settings.getSetting(id="views"))])+")")
xbmcplugin.endOfDirectory(addon_handle)


#635
def single(url):
def single(jsob,iconimage):
jdata = json.loads(jsob[0])#;i=0
for title in jdata:
title = jdata['title']
description = jdata['description']
duration = jdata['duration']
rating = jdata['rating']
pubdate = jdata['pubdate']
url = jdata['html5_url']
play(title,url,iconimage)


#636
def nature(url):
page = br.open(url).read()
jdata = json.loads(page);i=0
for title in jdata['page']['category']['videos']:
Expand All @@ -144,20 +176,20 @@ def single(url):
rating = jdata['page']['category']['videos'][i]['video']['rating']
video_id = jdata['page']['category']['videos'][i]['video']['id']
url = 'https://api.smithsonianearthtv.com:8443/channels/5DJZN6FN/responsives/' + str(video_id) + '?index=0&locale=en'
purl = 'plugin://plugin.video.smithsonian-earth?mode=636&url=' + urllib.quote_plus(url) + "&name=" + urllib.quote_plus(title) + "&iconimage=" + urllib.quote_plus(image)
purl = 'plugin://plugin.video.smithsonian-earth?mode=637&url=' + urllib.quote_plus(url) + "&name=" + urllib.quote_plus(title) + "&iconimage=" + urllib.quote_plus(image)
pubdate = jdata['page']['category']['videos'][i]['video']['pubdate']
li = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image);i=i+1
li.setProperty('fanart_image', defaultfanart)
li.setInfo(type="Video", infoLabels={"Title": title, "Plot": description, "Premiered": pubdate, "mpaa": rating})
li.addStreamInfo('video', { 'duration': duration })
xbmcplugin.addDirectoryItem(handle=addon_handle, url=purl, listitem=li)
xbmcplugin.setContent(addon_handle, 'episodes')
if views != 'false':
xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[3])+")")
if force_views != 'false':
xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[int(settings.getSetting(id="views"))])+")")
xbmcplugin.endOfDirectory(addon_handle)


#636
#637
def stream(name,url):
xbmc.log('URL: ' + str(url))
sign_in = br.open('https://api.smithsonianearthtv.com:8443/channels/5DJZN6FN/responsives/login')
Expand All @@ -166,23 +198,19 @@ def stream(name,url):
br['password'] = password
logged_in = br.submit()
check = logged_in.read()
device_id = re.compile(" device_id = '(.+?)'").findall(str(check))
xbmc.log('DEVICE_ID: ' + str(device_id),level=log_level)
dlsn = settings.getSetting(id="status")
if 'Log In' in check:
xbmcgui.Dialog().notification(plugin, 'Login Failed', defaultimage, 5000, False)
return
else:
if email in check:
if dlsn=='false':
xbmcgui.Dialog().notification(plugin, 'Login Successful', defaultimage, 2500, False)
else:
xbmcgui.Dialog().notification(plugin, 'Login Failed', defaultimage, 50000, False)
return
page = br.open(str(url)).read()
url = re.compile('html5_url":"(.+?)"').findall(page)
xbmc.log('M3U8_URL: ' + str(url))
urls = url[0].rpartition('/')
keys = urls[-1].rpartition('.')
q = settings.getSetting(id='quality')
q_key = 'v' + q +'_' + keys[0]
post_url = q_key + '/' + q_key + '.m3u8'
stream = urls[0] + '/' + post_url
play(name,stream,iconimage)
url = re.compile('html5_url":"(.+?)"').findall(page)[0]
xbmc.log('M3U8_URL: ' + str(url),level=log_level)
play(name,url,iconimage)
xbmcplugin.endOfDirectory(addon_handle)


Expand All @@ -199,6 +227,16 @@ def play(name,url,iconimage):
xbmcplugin.endOfDirectory(addon_handle)


#99
def PLAY(url):
listitem = xbmcgui.ListItem(path=url)
xbmc.log('### SETRESOLVEDURL ###', level=log_level)
listitem.setProperty('IsPlayable', 'true')
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
xbmc.log('URL: ' + str(url), level=log_level)
xbmcplugin.endOfDirectory(addon_handle)


def remove_non_ascii_1(text):
return ''.join(i for i in text if ord(i)<128)

Expand Down Expand Up @@ -228,7 +266,7 @@ def addDir2(name,url,mode,fanart,thumbnail,plot):
#commands = []
#commands.append ----- THIS WORKS! -----
#liz.addContextMenuItems([('Description', 'XBMC.RunScript(special://home/addons/plugin.video.smithsonian-earth/plot.py)')])
liz.addContextMenuItems([('Plot Info', 'XBMC.RunPlugin(%s?mode=681&url=%s)' % (sys.argv[0], url))])
#liz.addContextMenuItems([('Description', 'XBMC.RunPlugin(%s?mode=681&url=%s)' % (sys.argv[0], url))])
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True, totalItems=70)
return ok

Expand Down Expand Up @@ -287,30 +325,36 @@ def unescape(s):
except:
pass

xbmc.log("Mode: " + str(mode))
xbmc.log("URL: " + str(url))
xbmc.log("Name: " + str(name))
xbmc.log("Mode: " + str(mode), level=log_level)
xbmc.log("URL: " + str(url), level=log_level)
xbmc.log("Name: " + str(name), level=log_level)

if mode == None:# or url == None or len(url) < 1:
xbmc.log("Generate Smithsonian Earth Main Menu")
xbmc.log(("Generate Smithsonian Earth Main Menu"), level=log_level)
cats()
elif mode==630:
xbmc.log("Smithsonian Earth Categories")
xbmc.log(("Smithsonian Earth Categories"), level=log_level)
cats()
elif mode==633:
xbmc.log("Smithsonian Earth Videos")
xbmc.log(("Smithsonian Earth Videos"), level=log_level)
videos(url)
elif mode==634:
xbmc.log("Smithsonian Earth Series")
xbmc.log(("Smithsonian Earth Series"), level=log_level)
series(name,url,iconimage)
elif mode==635:
xbmc.log("Smithsonian Earth Single")
xbmc.log(("Smithsonian Earth Single"), level=log_level)
single(url)
elif mode==636:
xbmc.log("Smithsonian Earth Stream")
xbmc.log(("Smithsonian Nature Scenes"), level=log_level)
nature(url)
elif mode==637:
xbmc.log(("Smithsonian Nature Scenes Stream"), level=log_level)
stream(name,url)
elif mode==681:
xbmc.log("Smithsonian Earth Plot Info")
xbmc.log(("Smithsonian Earth Plot Info"), level=log_level)
plot_info(url)
elif mode==99:
xbmc.log(("Play Smithsonian Earth Video"), level=log_level)
PLAY(url)

xbmcplugin.endOfDirectory(int(sys.argv[1]))

0 comments on commit b3e3145

Please sign in to comment.