Skip to content

Commit

Permalink
letv
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Mar 15, 2020
1 parent 15469d2 commit 0d6d526
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 51 deletions.
2 changes: 1 addition & 1 deletion addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<addons>
<addon id="plugin.video.letv"
name="乐视网 (LeTV)"
version="2.2.0"
version="2.2.1"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
159508192198d4676b6961029e56db69 addons.xml
26e27f5ffa972871c830d92f0681e567 addons.xml
49 changes: 21 additions & 28 deletions plugin.video.funshion/lib/funshion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def mapping(num, base):
return res

class Funshion():
stream_types = ['sdvd', 'sdvd_h265', 'hd', 'hd_h265',
stream_types = ['sdvd', 'sdvd_h265', 'hd', 'hd_h265', 'shd',
'dvd', 'dvd_h265', 'tv', 'tv_h265'
]
a_mobile_url = 'http://m.fun.tv/implay/?mid=302555'
Expand Down Expand Up @@ -162,44 +162,37 @@ def video_from_vid(self, vid, **kwargs):

meta = loads(get_html(url))

if meta['retcode'] != '404':
streams = meta['playlist']
maxlevel = len(streams)
level = min(level, maxlevel-1)
stream = streams[level]
s = stream['playinfo'][0]
clear_info = self.dec_playinfo(s, self.coeff)
base_url = self.get_cdninfo(clear_info['hashid'])
token = base64.b64encode(clear_info['token'].encode('utf8'))
video_url = '{}?token={}&vf={}'.format(base_url, token, s['vf'])
else:
if meta['retcode'] == '404':
meta = loads(get_html('https://api1.fun.tv/ajax/new_playinfo/video/%s' % vid))
streams = meta['data']['files']
maxlevel = len(streams)
level = min(level, maxlevel-1)
s = streams[level]
clear_info = self.dec_playinfo(s, self.coeff)
base_url = self.get_cdninfo(clear_info['hashid'])
token = base64.b64encode(s['token'].encode('utf8'))
video_url = '{}?token={}&vf={}'.format(base_url, token, s['vf'])
else:
streams = meta['playlist']
maxlevel = len(streams)
level = min(level, maxlevel-1)
stream = streams[level]
s = stream['playinfo'][0]

clear_info = self.dec_playinfo(s, self.coeff)
base_url = self.get_cdninfo(clear_info['hashid'])
token = base64.b64encode(clear_info['token'].encode('utf-8'))
video_url = '{}?token={}&vf={}'.format(base_url, token, s['vf'])
return [video_url]

# Logics for single video until drama
#----------------------------------------------------------------------
def video_from_url(self, url, **kwargs):
vid = r1(r'https?://www.fun.tv/vplay/v-(\w+)', url)
if vid:
return self.video_from_vid(vid, single_video=True, **kwargs)
else:
vid = r1(r'https?://www.fun.tv/vplay/.*v-(\w+)', url)
if not vid:
epid = r1(r'https?://www.fun.tv/vplay/.*g-(\w+)', url)
url = 'http://pm.funshion.com/v5/media/episode?id={}&cl=mweb&uc=111'.format(epid)
html = get_html(url)
meta = loads(html)
vid = meta['episodes'][0]['id']
return self.video_from_vid(vid, **kwargs)
vid = r1(r'https?://www.fun.tv/vplay/.*v-(\w+)', url)
if not vid:
epid = r1(r'https?://www.fun.tv/vplay/.*g-(\w+)', url)
url = 'http://pm.funshion.com/v5/media/episode?id={}&cl=mweb&uc=111'.format(epid)
html = get_html(url)
meta = loads(html)
vid = meta['episodes'][0]['id'] # pick the first video in episodes

return self.video_from_vid(vid, **kwargs)


site = Funshion()
Expand Down
2 changes: 1 addition & 1 deletion plugin.video.letv/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.letv"
name="乐视网 (LeTV)"
version="2.2.0"
version="2.2.1"
provider-name="yfang1644">
<requires>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
Expand Down
43 changes: 23 additions & 20 deletions plugin.video.letv/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from common import get_html
from lib.letv import video_from_vid, quote_plus

GBANNER = '[COLOR green]%s[/COLOR]'
plugin = Plugin()
url_for = plugin.url_for

Expand Down Expand Up @@ -45,21 +46,6 @@ def httphead(url):
TRAILER_API = 'http://d.api.m.le.com/detail/getVideoTrailer?pid={}&platform=pc'
EPISODES_API = 'http://d.api.m.le.com/detail/episode?pid={}&pagesize=300&platform=pc'

############################################################################
def previous_page(endpoint, page, total_page, **kwargs):
if int(page) > 1:
page = str(int(page) - 1)
return [{'label': u'上一页 - {0}/{1}'.format(page, str(total_page)), 'path': plugin.url_for(endpoint, page=page, **kwargs)}]
else:
return []

def next_page(endpoint, page, total_page, **kwargs):
if int(page) < int(total_page):
page = str(int(page) + 1)
return [{'label': u'下一页 - {0}/{1}'.format(page, str(total_page)), 'path': plugin.url_for(endpoint, page=page, **kwargs)}]
else:
return []

@plugin.route('/filter/<url>/')
def filter(url):
html = get_html(url)
Expand Down Expand Up @@ -89,7 +75,14 @@ def filter(url):
idx = i
break

sel = dialog.select(title, [x.text for x in li])
content = []
for x in li:
if x.get('class'):
content += [GBANNER % re.sub('\r|\n|\t| ', '', x.text)]
else:
content += [x.text]

sel = dialog.select(title, content)

if sel >= 0:
try:
Expand Down Expand Up @@ -254,14 +247,19 @@ def videolist(url, page):

})

items += previous_page('videolist', page, 300, url=url)
if int(page) > 1:
p = int(page) - 1
items.append({
'label': '上一页 - {0}'.format(p),
'path': plugin.url_for('videolist', url=url, page=p)
})

newpage = '&pn=' + str(page)
frontUrl = re.sub('&pn=\d+', newpage, frontUrl)

html = get_html(frontUrl)
jsdata = loads(html)['data']['arr']
for item in jsdata:
jsdata = loads(html)['data']
for item in jsdata['arr']:
aid = item.get('aid') #album ID
eps = item.get('episodes', 0);
sub = item.get('subname')
Expand All @@ -288,7 +286,12 @@ def videolist(url, page):
'info': {'title': title, 'plot': item['description']},
})

items += next_page('videolist', page, 300, url=url)
if jsdata['more'] == True:
p = int(page) + 1
items.append({
'label': '下一页 - {0}'.format(p),
'path': plugin.url_for('videolist', url=url, page=p)
})

return items

Expand Down
Binary file not shown.

0 comments on commit 0d6d526

Please sign in to comment.