Skip to content

Commit

Permalink
add acfun to rrsp, youku2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Dec 16, 2017
1 parent f04c5bd commit 62567f6
Show file tree
Hide file tree
Showing 26 changed files with 461 additions and 1,500 deletions.
6 changes: 3 additions & 3 deletions addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
</addon>

<addon id="plugin.video.youku2"
name="优酷视频2(YouKu2)" version="1.0.1"
name="优酷视频2(YouKu2)" version="1.0.2"
provider-name="yfang1644">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
<import addon="plugin.video.cntv-video" version="1.0.8"/>
</requires>
Expand Down Expand Up @@ -526,7 +526,7 @@

<addon id="plugin.video.rrsp"
name="人人视频"
version="1.0.3"
version="1.0.4"
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 @@
5bb1b3da70a69cd175cb83de1dafde41 addons.xml
66eb21924d62f198cf8e0aceceedb88c addons.xml
Binary file modified plugin.audio.qingting/plugin.audio.qingting-1.0.1.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion plugin.video.rrsp/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.rrsp"
name="人人视频"
version="1.0.3"
version="1.0.4"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down
4 changes: 4 additions & 0 deletions plugin.video.rrsp/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.0.4 (2017.12.16)
- sort episodes
- add acfun.py. some videos come from ACFUN

v1.0.3 (2017.12.4)
- add local search, search videos

Expand Down
25 changes: 25 additions & 0 deletions plugin.video.rrsp/dbase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sqlite3
import json
import urllib
conn = sqlite3.connect('test.db')

c = conn.cursor()
c.execute('''CREATE TABLE MJINDEX
(ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL);''')

f = open('jss', 'r')
x = f.read()

js = json.loads(x)
for x in js:
name = x.encode('utf-8')
cmd = "INSERT INTO MJINDEX (ID, NAME) VALUES ({0}, \"{1}\")".format(js[x], name)
print cmd
c.execute(cmd)

conn.commit()
conn.close()
44 changes: 25 additions & 19 deletions plugin.video.rrsp/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
sys.path.append(os.path.join(ADDON_PATH, 'resources', 'lib'))

from xbmcswift2 import Plugin, ListItem, xbmc, xbmcgui

from rrmj import RenRenMeiJu
from acfun import video_from_url

from urlparse import parse_qsl
from urllib import urlencode
from json import loads, dumps
Expand Down Expand Up @@ -180,12 +183,8 @@ def movieCatList(catid):
moviecat = Meiju.movie_catname()['data']['categoryList']
dialog = xbmcgui.Dialog()
catlist = [x['name'] for x in moviecat]
cat_id = [x['id'] for x in moviecat]
sel = dialog.select('分类(可能不全)', ['全部'] + catlist)
if sel == 0:
catid = '0'
elif sel > 0:
catid = cat_id[sel-1]
catid = moviecat[sel-1]['id'] if sel > 0 else '0'

return movies(1, catid)

Expand Down Expand Up @@ -232,16 +231,20 @@ def videodetail(videoId, title):
video = Meiju.video_detail(videoId)
play_url = video['data']['playLink']
if play_url:
stackurl = play_url.split('|')
play_url = 'stack://' + ' , '.join(stackurl)
li = ListItem(title, path=play_url)
li.set_info('video', {'title': title})
plugin.set_resolved_url(li)
play_url = play_url.split('|')
else:
video = Meiju.video_detail2(videoId)
url = video['data']['videoDetailView']['playLink']
xbmcgui.Dialog().ok('视频地址' + url.encode('utf-8'),
'请使用其他插件搜索播放')
if 'acfun' in url:
play_url = video_from_url(url)
else:
xbmcgui.Dialog().ok('视频地址' + url.encode('utf-8'),
'请使用其他插件搜索播放')
return

stackurl = 'stack://' + ' , '.join(play_url)
plugin.set_resolved_url(stackurl)



@plugin.route('/leafCategory/<catid>/<page>')
Expand Down Expand Up @@ -364,7 +367,7 @@ def search(title, page):
items = []
if searchlist:
items.append({
'label': colorize(u'剧集', 'yellow'),
'label': colorize(u'剧集搜索-'+ title.decode('utf-8'), 'yellow'),
'path': url_for('stay')
})
for item in searchlist:
Expand Down Expand Up @@ -409,6 +412,7 @@ def search(title, page):
items += previous_page('search', page, total_page, title=title)
for x in searchlist['results']:
t = x.get('videoDuration', 0)
if int(t) < 0: t = 0
items.append({
'label': x['title'],
'path': url_for('videodetail',
Expand Down Expand Up @@ -477,8 +481,10 @@ def detail(seasonId):
'season': 0},
})

plugin.finish(items, sort_methods=['episode'])
return items
unsorted = [(dict_['info']['episode'], dict_) for dict_ in items]
unsorted.sort()
sorted = [dict_ for (key, dict_) in unsorted]
return sorted


@plugin.route('/play/<seasonId>/<index>/<Esid>', name='play_season')
Expand All @@ -488,11 +494,11 @@ def play(seasonId='', index='', Esid=''):
episode_sid = Esid
play_url, _ = Meiju.get_by_sid(episode_sid, plugin.get_setting('quality'))
if play_url is not None:
stackurl = play_url.split('|')
play_url = 'stack://' + ' , '.join(stackurl)
play_url = play_url.split('|')
stackurl = 'stack://' + ' , '.join(play_url)
add_history(seasonId, index, Esid, title)
li = ListItem(title+index,
path=play_url,
path=stackurl,
thumbnail=season_data.get('cover'))
li.set_info('video', {'title': title+index,
'plot': season_data.get('brief','')})
Expand Down Expand Up @@ -556,7 +562,7 @@ def update(page):
# main entrance
@plugin.route('/')
def index():
set_auto_play()
#set_auto_play()
yield {
'label': u'分类',
'path': url_for('category'),
Expand Down
Binary file added plugin.video.rrsp/local.db
Binary file not shown.
Binary file not shown.
117 changes: 117 additions & 0 deletions plugin.video.rrsp/resources/lib/acfun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env python

from common import get_html, r1, match1
from json import loads
import re
import base64
import time

def rc4(key, data):
c = list(range(256))
g = 0
for j in range(256):
g = (g + c[j] + ord(key[j % len(key)])) & 0xff
c[j], c[g] = c[g], c[j]

g = j = 0
f = ''
for m in range(len(data)):
j = (j + 1) & 0xff
g = (g + c[j]) & 0xff
c[j], c[g] = c[g], c[j]

t = data[m] if isinstance(data[m], int) else ord(data[m])
f += chr(t ^ c[(c[j] + c[g]) & 0xff])
return f


class ACfun():
def get_srt_json(self, id):
url = 'http://danmu.aixifan.com/V2/%s' % id
return get_html(url)

def youku_acfun_proxy(self, vid, sign, ref):
endpoint = 'http://player.acfun.cn/flash_data?vid={}&ct=85&ev=3&sign={}&time={}'
url = endpoint.format(vid, sign, str(int(time.time() * 1000)))
json_data = loads(get_html(url, headers=dict(referer=ref)))['data']
enc_text = base64.b64decode(json_data)
dec_text = rc4(b'8bdc7e1a', enc_text).decode('utf8')
youku_json = loads(dec_text)

yk_streams = {}
for stream in youku_json['stream']:
tp = stream['stream_type']
yk_streams[tp] = [], stream['total_size']
if stream.get('segs'):
for seg in stream['segs']:
yk_streams[tp][0].append(seg['url'])
else:
yk_streams[tp] = stream['m3u8'], stream['total_size']

return yk_streams

def video_from_vid(self, vid, **kwargs):
"""str, str, str, bool, bool ->None
Download Acfun video by vid.
Call Acfun API, decide which site to use, and pass the job to its
extractor.
"""

#first call the main parasing API
info = loads(get_html('http://www.acfun.tv/video/getVideo.aspx?id=' + vid))

sourceType = info['sourceType']

#decide sourceId to know which extractor to use
sourceId = info.get('sourceId', '')
# danmakuId = info['danmakuId']

#call extractor decided by sourceId
if sourceType == 'sina':
sina_download_by_vid(sourceId)
elif sourceType == 'youku':
youku_download_by_vid(sourceId, **kwargs)
elif sourceType == 'tudou':
tudou_download_by_iid(sourceId)
elif sourceType == 'qq':
qq_download_by_vid(sourceId)
elif sourceType == 'letv':
letvcloud_download_by_vu(sourceId, '2d8c027396')
elif sourceType == 'zhuzhan':
#As in Jul.28.2016, Acfun is using embsig to anti hotlink so we need to pass this
#In Mar. 2017 there is a dedicated ``acfun_proxy'' in youku cloud player
#old code removed
url = 'http://www.acfun.cn/v/ac' + vid
yk_streams = self.youku_acfun_proxy(info['sourceId'], info['encode'], url)
seq = ['mp4hd3', 'mp4hd2', 'mp4hd', 'flvhd', 'm3u8_flv']
for t in seq:
if yk_streams.get(t):
preferred = yk_streams[t]
break

return preferred[0]
else:
raise NotImplementedError(sourceType)


def video_from_url(self, url, **kwargs):
assert re.match(r'http://[^\.]*\.*acfun\.[^\.]+/\D/\D\D(\d+)', url)
html = get_html(url)

title = r1(r'data-title="([^"]+)"', html)
assert title
if match1(url, r'_(\d+)$'): # current P
title = title + " " + r1(r'active">([^<]*)', html)

vid = r1('data-vid="(\d+)"', html)
up = r1('data-name="([^"]+)"', html)
p_title = r1('active">([^<]+)', html)
title = '%s (%s)' % (title, up)
if p_title:
title = '%s - %s' % (title, p_title)
return self.video_from_vid(vid, **kwargs)

site = ACfun()
video_from_url = site.video_from_url
4 changes: 1 addition & 3 deletions plugin.video.rrsp/resources/lib/rrmj.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,14 @@ def get_token(self):
def get_by_sid(self, episodeSid, quality='super'):
API = '/video/findM3u8ByEpisodeSid'
API = '/video/findM3u8ByEpisodeSidAuth'
url = SERVER + API
headers = self.header
body = {
'episodeSid': episodeSid,
'quality': quality,
'seasonId': 0,
'token': headers['token']
}
ppp = get_html(url, data=urlencode(body), headers=headers)
data = loads(ppp)
data = self.get_json(API, data=urlencode(body))
if data['code'] != '0000':
return None, None
else:
Expand Down
88 changes: 88 additions & 0 deletions plugin.video.rrsp/scratch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import urllib2
from urllib import urlencode
import json
import gzip
import StringIO
import re

SERVER = "https://api.rr.tv"
TOKEN = '0cd2626c822d49d5a27c4424a299dbaa'
TOKEN = 'a65cb45354614c23bf3e30ca12e043d3'
TOKEN = '8e575ee9b50643368d1c0792eb1a3f22'
#TOKEN = '1d71c7d377bc4b81b0c607b622b84b4b'
#TOKEN = "79e7dc7de5814908bc11e62972b6b819"
TOKEN = '6b6cfdd3e90843c0a0914425638db7ef'
FAKE_HEADERS = {
"clientType": "android_RRMJ",
"clientVersion": "3.6.2",
"token": TOKEN,
'deviceId': '861134030056126',
'signature': '643c184f77372e364550e77adc0360cd',
"Authentication": "RRTV 470164b995ea4aa5a53f9e5cbceded472:IxIYBj:LPWfRb:I9gvePR5R2N8muXD7NWPCj"
};


UserAgent = 'PUClient/3.5.5 (iPhone; iOS 10.0.1; Scale/2.00)'
UserAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0'

def GetHttpData(url, data=None, cookie=None, headers=None):
# print 'url: %s, data: %s, headers: %s' % (url, data, headers)
req = urllib2.Request(url, data)
req.add_header('User-Agent', UserAgent)
req.add_header('Accept-encoding', 'gzip')
if cookie is not None:
req.add_header('Cookie', cookie)
if headers is not None:
for header in headers:
req.add_header(header, headers[header])

response = urllib2.urlopen(req, timeout=3)
httpdata = response.read()
if response.headers.get('content-encoding', None) == 'gzip':
httpdata = gzip.GzipFile(fileobj=StringIO.StringIO(httpdata)).read()
response.close()
match = re.compile('encoding=(.+?)"').findall(httpdata)
if not match:
match = re.compile('meta charset="(.+?)"').findall(httpdata)
if match:
charset = match[0].lower()
if (charset != 'utf-8') and (charset != 'utf8'):
httpdata = unicode(httpdata, charset).encode('utf8')
# print httpdata
return httpdata


class RenRenMeiJu():
"""docstring for RenRenMeiJu"""

def __init__(self):
self.header = FAKE_HEADERS

def get_json(self, api, data=None, pretty=False):
headers = self.header
html = GetHttpData(SERVER+api, data=data, headers=FAKE_HEADERS)
s = json.loads(html)
if pretty:
print headers
print json.dumps(s, sort_keys=True,
indent=4, separators=(',', ': '))
return html

def func(self, API='/v3plus', **kwargs):
return self.get_json(API, data=urlencode(kwargs))

#x = GetTokenX()
meiju=RenRenMeiJu()
API='/v3plus/season/detail'

for x in range(13000,14000):
html = meiju.func(API=API,seasonId=x)
js = json.loads(html)
if js['code'] != '0000':
print js['msg']
continue
print js['data']['season']['title'], js['data']['season']['id']

Loading

0 comments on commit 62567f6

Please sign in to comment.