Skip to content

Commit

Permalink
update funshion
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Mar 14, 2020
1 parent 74d0f9b commit 15469d2
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 67 deletions.
2 changes: 1 addition & 1 deletion addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@

<addon id="plugin.video.funshion"
name="风行视频(Funshion)"
version="2.1.10"
version="2.1.11"
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 @@
5463cdfe396dabf545b15e3163fffe98 addons.xml
159508192198d4676b6961029e56db69 addons.xml
2 changes: 1 addition & 1 deletion plugin.video.funshion/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.funshion"
name="风行视频(Funshion)"
version="2.1.10"
version="2.1.11"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down
53 changes: 9 additions & 44 deletions plugin.video.funshion/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,35 +102,6 @@ def filter(url):
return mainlist(url)


def playList(url):
html = get_html(url)
soup = BeautifulSoup(html, 'html.parser')

lists = soup.find_all('a', {'class': 'vd-list-item'})

if lists is None:
return []

items = []
for item in lists:
p_thumb = item.img.get('src')
if p_thumb is None:
p_thumb = item.img.get('_lazysrc', '')
d = item.find('i', {'class': 'vtime'})
duration = 0
for t in d.text.split(':'):
duration = duration * 60 + int(t)
items.append({
'label': item['title'],
'path': url_for('playvideo', url=httphead(item['href'])),
'thumbnail': p_thumb,
'is_playable': True,
'info': {'title': item['title'], 'duration': duration}
})

return items


def relatedList(url):
epid = r1('http?://www.fun.tv/vplay/.*g-(\w+)', url)
if not epid:
Expand Down Expand Up @@ -174,7 +145,12 @@ def relatedList(url):
return items

##########################################################################
def seriesList(url):
@plugin.route('/albumlist/<url>/')
def albumlist(url):
plugin.set_content('TVShows')
vid = r1('http?://www.fun.tv/vplay/v-(\w+)', url) # single video
epid = r1('http?://www.fun.tv/vplay/.*g-(\w+)', url) # list series

html = get_html(url + '?isajax=1')
data = loads(html)

Expand All @@ -195,26 +171,15 @@ def seriesList(url):
duration = 0
for t in item['duration'].split(':'):
duration = duration*60 + int(t)
title = item.get('name') or item.get('title')
items.append({
'label': item['name'],
'label': title,
'path': url_for('playvideo', url=httphead(item['url'])),
'thumbnail': item.get('pic') or infos['pic'],
'is_playable': True,
'info': {'title': item['name'], 'duration': duration,
'info': {'title': title, 'duration': duration,
'plot': infos['desc']}
})
return items

@plugin.route('/albumlist/<url>/')
def albumlist(url):
plugin.set_content('TVShows')
vid = r1('http?://www.fun.tv/vplay/v-(\w+)', url)
epid = r1('http?://www.fun.tv/vplay/.*g-(\w+)', url)
items = []
if vid:
items += playList(url) # play single video
elif epid:
items += seriesList(url) # list series

# add some related videos
items += relatedList(url)
Expand Down
53 changes: 34 additions & 19 deletions plugin.video.funshion/lib/funshion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from common import get_html, r1
import base64
import binascii
from random import choice
if sys.version[0]=='3':
from urllib.parse import urlparse, urljoin
else:
Expand Down Expand Up @@ -92,7 +91,7 @@ def fetch_magic(self, url):
def get_cdninfo(self, hashid):
url = 'http://jobsfe.funshion.com/query/v1/mp4/{}.json'.format(hashid)
meta = loads(get_html(url))
return choice(meta['playlist'][0]['urls']) # random pick
return meta['playlist'][0]['urls'][0]

def funshion_decrypt(self, a_bytes, coeff):
res_list = []
Expand All @@ -117,7 +116,7 @@ def funshion_decrypt_str(self, a_str, coeff):
if len(a_str) == 28 and a_str[-1] == '0':
data_bytes = base64.b64decode(a_str[:27] + '=')
clear = self.funshion_decrypt(data_bytes, coeff)
return binascii.hexlify(clear.encode('ut-f8')).upper()
return binascii.hexlify(clear.encode('utf-8')).upper()

data_bytes = base64.b64decode(a_str[2:])
return self.funshion_decrypt(data_bytes, coeff)
Expand All @@ -133,15 +132,19 @@ def checksum(self, sha1_str):
return False

def dec_playinfo(self, info, coeff):
clear = self.funshion_decrypt_str(info['infohash'], coeff)
hash = info.get('infohash')
if hash is None:
hash = info.get('hashid')

clear = self.funshion_decrypt_str(hash, coeff)
if self.checksum(clear):
token = 'token'
else:
clear = self.funshion_decrypt_str(info['infohash_prev'], coeff)
if self.checksum(clear):
token = 'token_prev'
else:
return
token = 'token_prev'

res = dict(hashid=clear[:40], token=self.funshion_decrypt_str(info[token], coeff))
return res
Expand All @@ -154,32 +157,44 @@ def video_from_vid(self, vid, **kwargs):

ep_url = self.video_ep if 'single_video' in kwargs else self.media_ep
url = ep_url.format(vid)
meta = loads(get_html(url))

streams = meta['playlist']
maxlevel = len(streams)
level = kwargs.get('level', 0)
level = min(level, maxlevel-1)
stream = streams[level]
definition = stream['code']
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'])

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:
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'])

return [video_url]

# Logics for single video until drama
#----------------------------------------------------------------------
def video_from_url(self, url, **kwargs):
vid = r1(r'http?://www.fun.tv/vplay/v-(\w+)', url)
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'http?://www.fun.tv/vplay/.*v-(\w+)', url)
vid = r1(r'https?://www.fun.tv/vplay/.*v-(\w+)', url)
if not vid:
epid = r1(r'http?://www.fun.tv/vplay/.*g-(\w+)', url)
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)
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion plugin.video.qq/lib/qq.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def video_from_vid(self, vid, **kwargs):
return videos[s[level]]

def video_from_url(self, url, **kwargs):
vid = match1(url, 'http[s]://.*/(\w+)\.html')
vid = match1(url, 'https?://.*/(\w+)\.html')

if vid and match1(url, '(^https?://film\.qq\.com)'):
url = 'https://v.qq.com/x/cover/%s.html' % vid
Expand Down

0 comments on commit 15469d2

Please sign in to comment.