Skip to content

Commit

Permalink
Update Hunt Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
MetalChris committed Nov 11, 2017
1 parent 4a0fe84 commit 4705b40
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 156 deletions.
21 changes: 13 additions & 8 deletions addons.xml
Expand Up @@ -84,11 +84,9 @@
</extension>
</addon>

<addon id="plugin.video.caa" name="CAA TV" version="2017.11.04" provider-name="MetalChris">
<addon id="plugin.video.caa" name="CAA TV" version="2017.11.05" provider-name="MetalChris">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.simplejson" version="3.3.0"/>
<import addon="script.module.requests" version="2.9.1"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
Expand All @@ -101,9 +99,16 @@
<platform>all</platform>
<license>GPL(v2) or Later</license>
<forum></forum>
<website>http://addons.the-antinet.net</website>
<website>http://www.caa.tv</website>
<email></email>
<source></source>
<source>https://github.com/MetalChris/repository.metalchris/tree/master/plugin.video.caa</source>
<news>v.2017.11.05[CR]- Code changes for Kodi compliance[CR]v.2017.11.04[CR]- Code cleanup[CR]v.2017.10.08[CR]- Fix for live streams (?)[CR]- Add subcategories for each sport[CR]v.2017.10.01[CR]- Initial release</news>
<assets>
<icon>resources/images/icon.png</icon>
<fanart>resources/images/fanart.jpg</fanart>
<screenshot>resources/images/screenshot01.png</screenshot>
<screenshot>resources/images/screenshot02.png</screenshot>
</assets>
</extension>
</addon>

Expand Down Expand Up @@ -805,7 +810,7 @@ Watch a Message, do Church Online Live, get Involved. Our mission is to lead peo
</extension>
</addon>

<addon id="repository.metalchris" name="MetalChris' Repository" version="2.9.5" provider-name="MetalChris">
<addon id="repository.metalchris" name="MetalChris' Repository" version="2.9.6" 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 @@ -1251,7 +1256,7 @@ The sanctuary houses the most diverse population of exotic cats in the world, wi
</extension>
</addon>

<addon id="plugin.video.hunt-channel" name="Hunt Channel" version="0.1.1" provider-name="MetalChris">
<addon id="plugin.video.hunt-channel" name="Hunt Channel" version="0.1.2" provider-name="MetalChris">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
Expand All @@ -1274,7 +1279,7 @@ The sanctuary houses the most diverse population of exotic cats in the world, wi
<website>http://www.huntchannel.tv</website>
<email></email>
<source></source>
<news>v.0.1.1[CR]Another attempt at fixing the Live Stream[CR]v.0.1.0[CR]- Fix for Live Stream[CR]- Remove Recently Added videos[CR]v.0.9.0[CR]- Fixes for videos without sound - I still hate vimeo![CR]v0.8.0[CR]- Fix to get all shows listed</news>
<news>v.0.1.2[CR]Fixex for website changes (2017.11.05)[CR]v.0.1.1[CR]Another attempt at fixing the Live Stream[CR]v.0.1.0[CR]- Fix for Live Stream[CR]- Remove Recently Added videos[CR]v.0.9.0[CR]- Fixes for videos without sound - I still hate vimeo![CR]v0.8.0[CR]- Fix to get all shows listed</news>
</extension>
</addon>
</addons>
2 changes: 1 addition & 1 deletion addons.xml.md5
@@ -1 +1 @@
87d9e888f3ad55a832b2aabd4301256c
a7eb8ab988cab5b6202b44b0bcdfe360
212 changes: 69 additions & 143 deletions plugin.video.hunt-channel/addon.py
Expand Up @@ -7,7 +7,7 @@
import urllib, urllib2, xbmcplugin, xbmcaddon, xbmcgui, htmllib, re, sys
from bs4 import BeautifulSoup
import html5lib
import simplejson as json
import json
import datetime
from pytz import timezone
from requests import Session
Expand Down Expand Up @@ -86,144 +86,75 @@ def prog():

#10
def cats(program):
addDir2('Live Stream' + ': ' + program,'http://www.huntchannel.tv/live/',12,defaultimage)
addDir('On Demand','http://www.huntchannel.tv',11,defaultimage)
xbmcplugin.endOfDirectory(addon_handle)


#11
def vod(url):
addDir('Featured','http://www.huntchannel.tv',13,defaulticon)
#addDir('Recently Added','http://huntchannel.tv/feed/',14,defaulticon)
addDir('All Shows','http://www.huntchannel.tv/wp-admin/admin-ajax.php',100,defaulticon)
addDir2('Live Stream' + ': ' + program,'http://www.huntchannel.tv/',12,defaultimage)
addDir('On Demand','http://www.huntchannel.tv/shows/',100,defaultimage)
xbmcplugin.endOfDirectory(addon_handle)


#12
def get_live(name,url,iconimage):
html = get_html(url)
soup = BeautifulSoup(html,'html5lib').find_all('div',{'id':'player-embed'})
iframe = str(re.compile('src="(.+?)"').findall(str(soup)))[2:-2].replace('html','js')
if 'http' not in iframe:
iframe = 'http' + iframe
xbmc.log('IFRAME: ' + str(iframe))
html = get_html(iframe)
#soup = BeautifulSoup(html,'html5lib').find_all('div',{'id':'player-embed'})
soup = BeautifulSoup(html,'html5lib').find_all('div',{'class':'entry-content'})
#xbmc.log('SOUP: ' + str(soup))
for iframe in soup:
i_url = iframe.find('iframe')['src']
#iframe = str(re.compile('src="(.+?)"').findall(str(soup)))[2:-2].replace('html','js')
#if 'http' not in iframe:
#iframe = 'http' + iframe
#xbmc.log('IFRAME: ' + str(i_url))
html = get_html(i_url)
m3u8 = str(re.compile('source0.src = (.+?);').findall(str(html)))[2:-2].split(", '")[-1].replace("')","")
xbmc.log('M3U8: ' + str(m3u8))
#xbmc.log('M3U8: ' + str(m3u8))
listitem = xbmcgui.ListItem('Hunt Channel' + ' ' + name, thumbnailImage=defaulticon)
listitem.setProperty('mimetype', 'video/x-mpegurl')
xbmc.Player().play( m3u8, listitem )
sys.exit()
xbmcplugin.endOfDirectory(addon_handle)


#13
def get_vod(url):
html = get_html(url)
soup = BeautifulSoup(html,'html5lib').find_all('div',{'class':'scroll-text'})
titles = re.compile('<li>(.+?)</li>').findall(str(soup))
for title in titles:
url = str(re.compile('href=(.+?)>').findall(str(title)))[3:-3]
title = striphtml(title).replace('&amp;','&')
add_directory2(title,url,30,defaultfanart,defaultimage,plot='')
xbmcplugin.endOfDirectory(addon_handle)


#14
def recent(url):
html = get_html(url)
soup = BeautifulSoup(html,'html5lib').find_all('item')
for item in soup:
title = item.find('title').string.encode('utf-8').title()
url = item.find('comments').string.split('#')[0]
add_directory2(title,url,30,defaultfanart,defaultimage,plot='')
xbmcplugin.endOfDirectory(addon_handle)


#21
def sc_videos(name,url):
html = get_html(url)
soup = BeautifulSoup(html,'html5lib').find_all('div',{'class':'entry-content'})
for item in reversed(soup):
title = (item.find('a')['title']).encode('utf-8').strip()
if item.find('img'):
image = item.find('img')['src']
else:
continue
url = item.find('a')['href']
add_directory2(title,url,31,defaultfanart,image,plot='')
soup = BeautifulSoup(html,'html5lib').find_all('div',{'class':'slideshow_container slide_container_small'})
#xbmc.log('SOUP: ' + str(soup))
for iframe in soup:
i_url = iframe.find('iframe')['src']
xbmc.log('IFRAME: ' + str(i_url))
html = get_html(i_url)
pjson = re.compile('playlist_videos = (.+?);\n').findall(str(html))
#xbmc.log('PJSON: ' + str(pjson[:300]))
data = json.loads(pjson[0])
for i in range(len(data)):
title = data[i]['title'].encode('utf-8')
url = data[i]['embed_code'].split('src=\"')[-1].rpartition('" ')[0]
image = data[i]['thumbnail'].replace('200','400').replace('150','300').split('?')[0]
add_directory(title,url,22,defaultfanart,image,plot='')
#xbmc.log('URL: ' + str(url))
xbmcplugin.setContent(addon_handle, 'episodes')
xbmcplugin.endOfDirectory(addon_handle)


#30
def hstreams(name,url):
response = get_html(url)
soup = BeautifulSoup(response,'html5lib').find_all('iframe')[0]
iframe = re.compile('src="(.+?)"').findall(str(soup))[0]
source = get_iframe(iframe)
#thumbnail = re.compile('base":"(.+?)"').findall(str(source))[-1]
best(source)


#31
def s_streams(name,url):
response = get_html(url)
#xbmc.log(str(url))
vsoup = BeautifulSoup(response,'html5lib').find_all('input',{'name':'main_video_url'})
vkey = str(re.compile('value="(.+?)"').findall(str(vsoup)))[2:-2]
vurl = 'https://player.vimeo.com/video/' + vkey
#xbmc.log('VURL: ' + str(vurl))
source = get_iframe(vurl)
best(source)


def best(data):
vjson = re.compile('progressive":(.+?)},"lang').findall(str(data))
mp4 = (re.compile('"url":"(.+?)"').findall(str(vjson)));i = 0
#xbmc.log('MP4: ' + str(len(mp4)))
if len(mp4) < 1:
xbmcgui.Dialog().notification(name, 'No Stream Available', defaultimage, 5000, False)
sys.exit()
data = json.loads(vjson[0])
elements = [];links = []
for stream in data:
stream = data[i]['url']
#xbmc.log('STREAM: ' + str(stream))
quality = data[i]['quality'];i = i + 1
#xbmc.log('QUALITY: ' + str(quality))
elements.append(quality)
links.append(stream)
hi = max(elements)
i = elements.index(hi)
#ret = xbmcgui.Dialog().select('Select Quality',elements)
#xbmc.log(str(ret))
stream = links[i]
#22
def sc_streams(name,url):
html = get_html(url)
source = re.compile('source0.src = (.+?)\\);').findall(str(html))[0].split(' ')
#xbmc.log('SOURCE: ' + str(source[-1].replace('\'','')))
listitem = xbmcgui.ListItem(name, thumbnailImage=defaultimage)
xbmc.Player().play( stream, listitem )
xbmc.Player().play( source[-1].replace('\'',''), listitem )
sys.exit()
xbmcplugin.endOfDirectory(addon_handle)


#100
def more(url):
for i in range(0,3):
data = {'action':'load_more','page':i,'template':'cactus-channel/content-listing','vars[post_type]':'ct_channel','vars[orderby]':'title','vars[order]':'ASC'}
session = Session()
session.head('http://www.huntchannel.tv')
response = session.post(
url ='http://www.huntchannel.tv/wp-admin/admin-ajax.php',
data=data,
headers=headers)
soup = BeautifulSoup(response.text,'html5lib').find_all('div',{'class':'entry-content'})
for item in soup:
title = (item.find('a')['title']).encode('utf-8').strip()
if item.find('img'):
image = item.find('img')['src']
else:
image = defaultimage
url = item.find('a')['href']
add_directory2(title,url,21,defaultfanart,image,plot='')
html = get_html(url)
soup = BeautifulSoup(html,'html5lib').find_all('div',{'class':'inner-entry'})
xbmc.log('SOUP: ' + str(len(soup)))
for title in soup:
show = title.find('h1').text.encode('utf-8')
url = title.find('a')['href']
image = title.find('img')['src']
add_directory2(show,url,21,defaultfanart,image,plot='')
xbmcplugin.endOfDirectory(addon_handle)


Expand All @@ -249,17 +180,30 @@ def hplay(name,url,iconimage):
xbmcplugin.endOfDirectory(addon_handle)


def add_directory(name,url,mode,fanart,thumbnail,plot):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name) + "&thumbnail=" + urllib.quote_plus(thumbnail)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=thumbnail)
liz.setInfo( type="Video", infoLabels={ "Title": name,
"plot": plot} )
if not fanart:
fanart=''
liz.setProperty('fanart_image',fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False, totalItems=100)
return ok


def add_directory2(name,url,mode,fanart,thumbnail,plot):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name) + "&thumbnail=" + urllib.quote_plus(thumbnail)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=thumbnail)
liz.setInfo( type="Video", infoLabels={ "Title": name,
"plot": plot} )
if not fanart:
fanart=''
liz.setProperty('fanart_image',fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True, totalItems=100)
return ok
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name) + "&thumbnail=" + urllib.quote_plus(thumbnail)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=thumbnail)
liz.setInfo( type="Video", infoLabels={ "Title": name,
"plot": plot} )
if not fanart:
fanart=''
liz.setProperty('fanart_image',fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True, totalItems=100)
return ok

def get_html(url):
req = urllib2.Request(url)
Expand Down Expand Up @@ -377,33 +321,15 @@ def unescape(s):
elif mode==10:
xbmc.log('Hunt Channel Categories')
cats(program)
elif mode==11:
xbmc.log('Hunt Channel VOD')
vod(url)
elif mode==12:
xbmc.log('Hunt Channel Live')
get_live(name,url,iconimage)
elif mode==13:
xbmc.log('Hunt Channel Featured')
get_vod(url)
elif mode==14:
xbmc.log('Hunt Channel Recent')
recent(url)
elif mode==30:
xbmc.log("Hunt Channel Streams")
hstreams(name,url)
elif mode==21:
xbmc.log("Hunt Channel Videos")
sc_videos(name,url)
elif mode==31:
xbmc.log("Hunt Channel Streams")
s_streams(name,url)
elif mode==40:
xbmc.log("Hunt Channel Live")
play(name,url,iconimage)
elif mode==50:
xbmc.log("Hunt Channel Program")
prog()
elif mode==22:
xbmc.log("Hunt Channel Videos")
sc_streams(name,url)
elif mode==100:
xbmc.log("Hunt Channel Shows")
more(url)
Expand Down
4 changes: 2 additions & 2 deletions plugin.video.hunt-channel/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.hunt-channel" name="Hunt Channel" version="0.1.1" provider-name="MetalChris">
<addon id="plugin.video.hunt-channel" name="Hunt Channel" version="0.1.2" provider-name="MetalChris">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
Expand All @@ -22,6 +22,6 @@
<website>http://www.huntchannel.tv</website>
<email></email>
<source></source>
<news>v.0.1.1[CR]Another attempt at fixing the Live Stream[CR]v.0.1.0[CR]- Fix for Live Stream[CR]- Remove Recently Added videos[CR]v.0.9.0[CR]- Fixes for videos without sound - I still hate vimeo![CR]v0.8.0[CR]- Fix to get all shows listed</news>
<news>v.0.1.2[CR]Fixex for website changes (2017.11.05)[CR]v.0.1.1[CR]Another attempt at fixing the Live Stream[CR]v.0.1.0[CR]- Fix for Live Stream[CR]- Remove Recently Added videos[CR]v.0.9.0[CR]- Fixes for videos without sound - I still hate vimeo![CR]v0.8.0[CR]- Fix to get all shows listed</news>
</extension>
</addon>
3 changes: 3 additions & 0 deletions plugin.video.hunt-channel/changelog.txt
@@ -1,3 +1,6 @@
Version 0.1.2
- Fixes for website changes (2017.11.05)

Version 0.1.1
- Another attempt at fixing the Live Stream

Expand Down
2 changes: 1 addition & 1 deletion repository.metalchris/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="repository.metalchris" name="MetalChris' Repository" version="2.9.5" provider-name="MetalChris">
<addon id="repository.metalchris" name="MetalChris' Repository" version="2.9.6" 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

0 comments on commit 4705b40

Please sign in to comment.