Skip to content

Commit

Permalink
huya unescape url
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Apr 1, 2020
1 parent c60dc4d commit c8956c4
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 185 deletions.
4 changes: 2 additions & 2 deletions addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

<addon id="plugin.video.huya"
name="虎牙直播"
version="0.9.3"
version="0.9.4"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down Expand Up @@ -331,7 +331,7 @@

<addon id="plugin.video.mgtv"
name="芒果TV"
version="1.1.6"
version="1.1.7"
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 @@
38a1f7db1b5f7b0b57b3191be91fc243 addons.xml
f89cb90ade67477b5819e3688194a3d9 addons.xml
2 changes: 1 addition & 1 deletion plugin.video.huya/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.huya"
name="虎牙直播"
version="0.9.3"
version="0.9.4"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down
10 changes: 9 additions & 1 deletion plugin.video.huya/default.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from xbmcswift2 import Plugin
from common import get_html, r1
from json import loads
import random
if sys.version[0] == '3':
from html import unescape
else:
import HTMLParser
def unescape(s):
html_parser = HTMLParser.HTMLParser()
return html_parser.unescape(s)

HOST = 'https://www.huya.com/'
playurl = 'https://al.hls.huya.com/huyalive'
Expand Down Expand Up @@ -54,7 +62,7 @@ def playvideo(room):
sHlsAntiCode = stream_info['sHlsAntiCode']
hls_url = u'{0}/{1}.{2}?{3}'.format(sHlsUrl, sStreamName, sHlsUrlSuffix, sHlsAntiCode)

plugin.set_resolved_url(hls_url)
plugin.set_resolved_url(unescape(hls_url))


@plugin.route('/categorylist/<dataid>/<page>/')
Expand Down
Binary file not shown.
25 changes: 19 additions & 6 deletions plugin.video.meiju/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,22 @@ def ttcategory(url):
tree = soup.findAll('li', {'class': 'subject-item'})
items = []
for item in tree:
try:
info = u'[COLOR pink]({})[/COLOR]'.format(item.span.text)
except:
info = ''
items.append({
'label': item.img['title'],
'label': item.img['title'] + info,
'path': url_for('ttepisodes' ,url=item.a['href']),
'thumbnail': item.img['data-src']
'thumbnail': item.img['data-src'],
'info': {'title': item.img['title'], 'plot': item.p.text}
})

# 分页
items.append({
'label': BANNER.format('分页'),
'path': url_for('stay')
})
tree = soup.findAll('div', {'class': 'page_navi'})
pages = tree[0].findAll('a')
for page in pages:
Expand Down Expand Up @@ -110,6 +119,8 @@ def yyepisodes(url):
soup = BeautifulSoup(html, 'html.parser')
tree = soup.findAll('div', {'class':'tab_set_info'})

info = r1('<meta name="description.+?content="([^"]+)"', html)

items = []
for sect in tree:
if u'相关推荐' in sect.text:
Expand Down Expand Up @@ -144,7 +155,7 @@ def yyepisodes(url):
'label': item.text,
'path': url_for('yyplay', url=href),
'is_playable': True,
'info': {'title': item.text}
'info': {'title': item.text, 'plot': info}
})

return items
Expand All @@ -159,11 +170,11 @@ def yycategory(url):
years = tree[0].findAll('li')
items = []

# 年份
items.append({
'label': BANNER.format('年份'),
'path': url_for('stay')
})
# 年份
for item in years[1:]:
title = item.text
try:
Expand All @@ -176,6 +187,7 @@ def yycategory(url):
'path': url_for('yycategory', url=href)
})

# 剧集
items.append({
'label': BANNER.format('剧集'),
'path': url_for('stay')
Expand All @@ -188,13 +200,14 @@ def yycategory(url):
try:
info = u'[COLOR pink]({})[/COLOR]'.format(item.span.text)
except:
info = 'XXX'
info = ''
items.append({
'label': title + info,
'path': url_for('yyepisodes', url=href),
'thumbnail': img
})

# 分页
items.append({
'label': BANNER.format('分页'),
'path': url_for('stay')
Expand All @@ -219,7 +232,7 @@ def yyetss():
soup = BeautifulSoup(html, 'html.parser')
tree = soup.findAll('li')
items = []
for item in tree[2:-1]:
for item in tree[2:-2]:
url = item.a['href']
if url[0] == '/': url = YYETSS + url
items.append({
Expand Down
Binary file modified plugin.video.meiju/plugin.video.meiju-1.0.0.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion plugin.video.mgtv/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.mgtv"
name="芒果TV"
version="1.1.6"
version="1.1.7"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down
87 changes: 35 additions & 52 deletions plugin.video.mgtv/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
plugin = Plugin()
url_for = plugin.url_for

# Plugin constants
__addonid__ = plugin.addon.getAddonInfo('id')
__addonname__ = plugin.addon.getAddonInfo('name')
__cwd__ = plugin.addon.getAddonInfo('path')

BANNER_FMT = '[COLOR FFDEB887]%s[/COLOR]'
BANNER_FMT2 = '[COLOR FFDE0087]%s[/COLOR]'
INDENT_FMT0 = '[COLOR FFDEB887] %s[/COLOR]'
Expand Down Expand Up @@ -60,7 +55,7 @@ def search():
url = p_url + quote_plus(keyword)
html = get_html(url)
tree = BeautifulSoup(html, 'html.parser')
soup = tree.find_all('div', {'class': 'result-content'})
soup = tree.findAll('div', {'class': 'result-content'})
items = []
for x in soup:
try:
Expand All @@ -82,34 +77,23 @@ def changeList(url):
soup = BeautifulSoup(html, 'html.parser')
tree = soup.findAll('div', {'class': 'm-tag-type'})

surl = url.split('/')
purl = surl[-1].split('-')

dialog = xbmcgui.Dialog()

filter = ''
for iclass in soup:
title = iclass.find('h5', {'class': 'u-title'}).text
si = iclass.find_all('a')
list = []
for subitem in si:
list.append(subitem.text)
sel = dialog.select(title, list)

if sel < 0:
continue

filter += u'|' + title + u'(' + si[sel].text + u')'
seurl = si[sel]['onclick'].split('/')[-1]
seurl = seurl.split('-')
item = tree[0]
title = item.find('h5', {'class': 'u-title'}).text
si = item.findAll('a')

for i in range(0, len(purl)):
if seurl[i] != '':
purl[i] = seurl[i]
content = [x.text for x in si]
sel = dialog.select(title, content)
if sel >= 0:
urlstr = str(si[sel])
surl = r1("'(/.+?)'", urlstr)
if surl:
url = surl
filter = si[sel].text.encode('utf-8')

surl[-1] = '-'.join(purl)
url = '/'.join(surl)
mainlist(url, filter)
url = httphead(url)
return mainlist(url, filter)


@plugin.route('/episodelist/<url>/<id>/<page>/')
Expand Down Expand Up @@ -184,17 +168,17 @@ def mainlist(url, filter):
plugin.set_content('TVShows')
filtitle = '' if filter == '0' else filter
items = [{
'label': BANNER_FMT % (u'[分类过滤]' + filtitle),
'label': BANNER_FMT % ('[分类过滤]' + filtitle),
'path': url_for('changeList', url=url)
}]

html = get_html(url)
tree = BeautifulSoup(html, 'html.parser')
soup = BeautifulSoup(html, 'html.parser')

soups = tree.find_all('div', {'class': 'm-result-list'})
tree = soup.findAll('div', {'class': 'm-result-list'})

soup= soups[0].find_all('li', {'class': 'm-result-list-item'})
for item in soup:
tree = tree[0].findAll('li', {'class': 'm-result-list-item'})
for item in tree:
t = item.find('a', {'class': 'u-title'})
title = t.text
href = t['href']
Expand Down Expand Up @@ -222,25 +206,24 @@ def mainlist(url, filter):
})

# multiple pages
setpage = tree.find_all('div', {'class': 'w-pages'})
setpage = soup.findAll('div', {'class': 'w-pages'})
try:
pages = setpage[0].find_all('li')
for page in pages:
try:
title = page.a['title']
except:
continue
href = page.a['href']
if href == 'javascript:;':
continue
else:
href = httphead(href)
items.append({
'label': BANNER_FMT % title,
'path': url_for('mainlist', url=href, filter=filter)
})
pages = setpage[0].findAll('li')
except:
pass
return items

for page in pages:
title = page.a.get('title', '')
href = page.a.get('href')
print "XXXXXXXXXXXXXXXXX", href
if href == 'javascript:;' or title == '':
continue
href = httphead(href)
items.append({
'label': BANNER_FMT % title,
'path': url_for('mainlist', url=href, filter=filter)
})

return items

@plugin.route('/')
Expand Down
2 changes: 1 addition & 1 deletion plugin.video.mgtv/lib/mgtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def vid_from_url(self, url, **kwargs):
def get_mgtv_real_url(self, m3u_url, **kwargs):
"""str->list of str
Give you the real URLs."""
split = urlparse.urlsplit(m3u_url)
split = urlsplit(m3u_url)

base_url = "{scheme}://{netloc}{path}/".format(scheme=split[0],
netloc=split[1],
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions plugin.video.youku/addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name="优酷视频" version="2.0.2"
provider-name="yfang1644">
<requires>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
<import addon="script.module.geturl" version="2.0.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
Expand Down
Loading

0 comments on commit c8956c4

Please sign in to comment.