Skip to content

Commit

Permalink
update baidu video
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Aug 30, 2018
1 parent 32aac61 commit 6346a6e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 34 deletions.
59 changes: 36 additions & 23 deletions plugin.video.baidu/addon.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
#!/usr/bin/python
#coding=utf-8

from xbmcswift2 import Plugin, xbmc, ListItem
from xbmcswift2 import Plugin, xbmc, xbmcgui, ListItem
import re
from urllib import quote_plus, unquote_plus, urlencode
import urlparse
from urllib import unquote_plus, urlencode
from common import get_html

from iqiyi import IQiyi
from qq import QQ
from youku import Youku
from pptv import PPTV
from sohu import Sohu
from funshion import Funshion
from letv import LeTV
from mgtv import MGTV
from iqiyi import video_from_url as video_from_iqiyi
from qq import video_from_url as video_from_qq
from youku import video_from_url as video_from_youku
from pptv import video_from_url as video_from_pptv
from sohu import video_from_url as video_from_sohu
from funshion import video_from_url as video_from_funshion
from letv import video_from_url as video_from_letv
from mgtv import video_from_url as video_from_mgtv

from json import loads, dumps
from bs4 import BeautifulSoup

BANNER_FMT = '[COLOR gold]%s[/COLOR]'
BANNER_FMT2 = '[COLOR pink][%s][/COLOR]'

HOST = 'http://v.baidu.com'

plugin = Plugin()
url_for = plugin.url_for

__cwd__ = plugin.addon.getAddonInfo('path')
__m3u8__ = __cwd__ + '/temp.m3u8'
BANNER_FMT = '[COLOR gold]%s[/COLOR]'
BANNER_FMT2 = '[COLOR pink][%s][/COLOR]'


def previous_page(endpoint, page, total_page, **kwargs):
if int(page) > 1:
info = loads(kwargs['info'])
Expand Down Expand Up @@ -102,22 +106,32 @@ def play(link, title):
page = get_html(link)
playurl = re.compile('a href="(http.+?)\"').findall(page)[0]

if 'sohu.com' in playurl:
site = Sohu()
if ('le.com' in playurl) or ('letv.com' in playurl):
videourl = video_from_letv(playurl, m3u8=__m3u8__)
plugin.set_resolved_url(__m3u8__)
return

elif 'sohu.com' in playurl:
videourl = video_from_sohu
elif 'qq.com' in playurl:
site = QQ()
videourl = video_from_qq
elif 'iqiyi.com' in playurl:
site = IQiyi()
split = urlparse.urlsplit(playurl)
playurl = '{scheme}://{netloc}{path}/'.format(scheme=split[0],
netloc=split[1],
path=split[2])
videourl = video_from_iqiyi
elif 'fun.tv' in playurl:
site = Funshion()
videourl = video_from_funshion
elif 'youku.com' in playurl:
site = Youku()
videourl = video_from_youku
elif 'mgtv.com' in playurl:
site = MGTV()
videourl = video_from_mgtv
else:
pass
xbmcgui.Dialog().ok(plugin.addon.getAddonInfo('name'), '地址不能解析')
return

urls = site.video_from_url(playurl)
urls = videourl(playurl)
stackurl = 'stack://' + ' , '.join(urls)
li = ListItem(title, path=stackurl)
li.set_info('video', {'title': title})
Expand Down Expand Up @@ -203,7 +217,6 @@ def channellist(url, info):
page = req['pn']
#'http://v.baidu.com/channel/amuse?format=json&pn=1'
api = HOST + '/' + url + '?format=json&pn=' + str(page)
print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",api
html = get_html(api)
data = loads(html)['data']
videos = data['videos']
Expand Down
Binary file modified plugin.video.baidu/plugin.video.baidu-1.1.0.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions plugin.video.iqiyi/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def playvideo(tvId, vid, title):
sel = 1
urls = video_from_vid(tvId, vid, level=sel)
if urls is None:
xbmcgui.Dialog().ok(__addonname__, '无法播放此视频')
xbmcgui.Dialog().ok(plugin.addon.getAddonInfo('name'), '无法播放此视频')
return

stackurl = 'stack://' + ' , '.join(urls)
Expand Down Expand Up @@ -327,7 +327,7 @@ def search():

@plugin.route('/videolist/<url>')
def videolist(url):
plugin.set_content('videos')
plugin.set_content('TVShows')
html = get_html(url)
html = re.sub('\t|\r|\n', ' ', html)
tree = BeautifulSoup(html, 'html.parser')
Expand Down
Binary file modified plugin.video.iqiyi/plugin.video.iqiyi-2.4.0.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions plugin.video.mgtv/lib/mgtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def get_mgtv_real_url(self, m3u_url, **kwargs):
split = urlparse.urlsplit(m3u_url)

base_url = "{scheme}://{netloc}{path}/".format(scheme=split[0],
netloc=split[1],
path=dirname(split[2]))
netloc=split[1],
path=dirname(split[2]))

# get the REAL M3U url, maybe to be changed later?
content = get_html(m3u_url)
Expand Down
8 changes: 3 additions & 5 deletions plugin.video.rrsp/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

import os
import sys
import xbmcaddon

ADDON = xbmcaddon.Addon()
ADDON_PATH = ADDON.getAddonInfo('path').decode("utf-8")
sys.path.append(os.path.join(ADDON_PATH, 'lib'))

from xbmcswift2 import Plugin, ListItem, xbmc, xbmcgui

Expand Down Expand Up @@ -51,6 +46,9 @@
plugin = Plugin()
url_for = plugin.url_for

ADDON_PATH = plugin.addon.getAddonInfo('path').decode("utf-8")
sys.path.append(os.path.join(ADDON_PATH, 'lib'))

conn = sqlite3.connect(ADDON_PATH + '/local.db')
cur = conn.cursor()

Expand Down
4 changes: 2 additions & 2 deletions plugin.video.sohuvideo/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def videolist(name, url):
})

vlists = tree.find_all('ul', {'class': 'st-list'})
lists = vlists[0].find_all('li')
lists = [] if len(vlists) == 0 else vlists[0].find_all('li')

for item in lists:
pic = item.find('div', {'class': 'st-pic'})
Expand Down Expand Up @@ -155,7 +155,7 @@ def videolist(name, url):
})

pages = tree.find_all('div', {'class': 'ssPages area'})
pages = pages[0].find_all('a')
pages = [] if len(pages) == 0 else pages[0].find_all('a')
for page in pages:
items.append({
'label': page['title'].encode('utf-8'),
Expand Down

0 comments on commit 6346a6e

Please sign in to comment.