Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
update moonplayer ver 0.49
Browse files Browse the repository at this point in the history
  • Loading branch information
1dot75cm committed Dec 5, 2015
1 parent 78a3fba commit aa4dc34
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 77 deletions.
159 changes: 96 additions & 63 deletions rpms/SOURCES/moonplayer/plugin_iqiyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,14 @@
import re
import moonplayer
import json
import hashlib
from uuid import uuid4
from random import random, randint
from math import floor
from moonplayer_utils import list_links

## hosts
hosts = ('www.iqiyi.com',)

## search
def search(kw, page):
kw = kw.replace(' ', '%20')
url = 'http://so.iqiyi.com/so/q_%s_ctg__t_0_page_%d_p_1_qc_0_rd__site_iqiyi_m_0' % (kw, page)
moonplayer.get_url(url, search_cb, kw)

def search_cb(content, keyword):
#movies and tv series
result = list_links(content, 'http://www.iqiyi.com/lib/m_')
n = len(result) / 2
#album
result += list_links(content, 'http://www.iqiyi.com/a_')
n2 = len(result) / 2
#single video
result += list_links(content, 'http://www.iqiyi.com/w_', keyword)
result += list_links(content, 'http://www.iqiyi.com/v_', keyword)
moonplayer.show_list(result)
for i in xrange(n):
moonplayer.set_list_item_color(i, '#0000ff')
for i in xrange(n, n2):
moonplayer.set_list_item_color(i, '#ff00ff')

## parse
def parse(url, options):
Expand All @@ -52,10 +34,36 @@ def parse(url, options):
class Parser(object):
def __init__(self):
pass

def mix(self, tvid):
enc = ['97596c0abee04ab49ba25564161ad225']
tm = str(randint(2000,4000))
src = 'eknas'
enc.append(str(tm))
enc.append(tvid)
sc = hashlib.new('md5', "".join(enc)).hexdigest()
return tm,sc,src

def getVRSXORCode(self, arg1, arg2):
loc3 = arg2 % 3
if loc3 == 1:
return arg1 ^ 121
if loc3 == 2:
return arg1 ^ 72
return arg1 ^ 103

def getVrsEncodeCode(self, vlink):
loc6 = 0
loc2 = ''
loc3 = vlink.split("-")
loc4 = len(loc3)
for i in range(loc4-1,-1,-1):
loc6 = self.getVRSXORCode(int(loc3[loc4-i-1],16),i)
loc2 += chr(loc6)
return loc2[::-1]

def feed(self, url, options, clip_number = -1):
def feed(self, url, options):
self.origin_url = url
self.clip_number = clip_number
moonplayer.get_url(url, self.parse_vid, options)

def parse_vid(self, content, options):
Expand All @@ -67,22 +75,38 @@ def parse_vid(self, content, options):
tvid_match = tvid_re.search(content)
vid_match = vid_re.search(content)
if tvid_match and vid_match:
self.uid = uuid4().hex
tvid = tvid_match.group(1)
vid = vid_match.group(1)
url = 'http://cache.video.qiyi.com/vd/%s/%s/' % (tvid, vid)
moonplayer.get_url(url, self.parse_vurl, options)
tm,sc,src = self.mix(tvid)
url = 'http://cache.video.qiyi.com/vms?key=fvip&src=1702633101b340d8917a69cf8a4b8c7' +\
"&tvId="+tvid+"&vid="+vid+"&vinfo=1&tm="+tm+\
"&enc="+sc+\
"&qyid="+self.uid+"&tn="+str(random()) +"&um=1" +\
"&authkey="+hashlib.new('md5', hashlib.new('md5', '').hexdigest()+str(tm)+tvid).hexdigest()
moonplayer.get_url(url, self.parse_vms, options)
else:
moonplayer.warn('Fail!')

def parse_vurl(self, content, options):

def parse_vms(self, content, options):
info = json.loads(content)
if info['code'] != 'A000000':
moonplayer.warn('Code Error')
return
if info["data"]['vp']["tkl"]=='':
moonplayer.warn('Error: empty data.')
return
# Read urls of all qualities
root = json.loads(content)
vs = root[u'tkl'][0][u'vs']
vs = info["data"]["vp"]["tkl"][0]["vs"]
bids = [None] * 5
for v in vs:
bid = int(v[u'bid']) - 1
if bid < 5:
bids[bid] = ['http://data.video.qiyi.com/videos' + item[u'l'] for item in v[u'fs']]
if bid < 5 and bid >= 0:
bids[bid] = v['fs']
if not v["fs"][0]["l"].startswith("/"):
tmp = self.getVrsEncodeCode(v["fs"][0]["l"])
if tmp.endswith('mp4'):
bids[bid] = v["flvs"]
# Select quality
if options & moonplayer.OPT_QL_SUPER:
q = 3
Expand All @@ -92,47 +116,56 @@ def parse_vurl(self, content, options):
q = 0
for i in xrange(q, -1, -1):
if bids[i]:
self.urls = bids[i]
self.video_links = bids[i]
break
if options & moonplayer.OPT_DOWNLOAD and bids[4]:
if moonplayer.question('是否下载1080P版本?'):
self.urls = bids[4]
self.video_links = bids[4]

# Get video's key
first_uid = self.urls[0].split('/')[-1].split('.')[0]
self.suffix = str(self.urls[0].split('.')[-1])
url = 'http://data.video.qiyi.com/' + first_uid + '.ts'
self.urls = []
self.vlinks = []
self.key_roots = []
self.info = info
for i in self.video_links:
vlink = i['l']
if not vlink.startswith('/'):
vlink = self.getVrsEncodeCode(vlink)
self.vlinks.append(vlink)
self.key_roots.append(vlink.split("/")[-1].split(".")[0])
url = "http://data.video.qiyi.com/t?tn=" + str(random())
moonplayer.get_url(url, self.parse_key, options)



def parse_key(self, content, options):
result = []
key = moonplayer.final_url.split('key=')[1]
for i in xrange(len(self.urls)):
name = '%s_%d.%s' % (self.name, i, self.suffix)
result.append(name) #name
result.append(self.urls[i] + '?key=' + key) #url
time = json.loads(content)["t"]
t = str(int(floor(int(time)/(10*60.0))))
tp = ")(*&^flash@#$%a" #magic from swf
for i in xrange(len(self.key_roots)):
key = hashlib.new("md5", t+tp+self.key_roots[i]).hexdigest()
baseurl = self.info["data"]["vp"]["du"].split("/")
baseurl.insert(-1, key)
url = "/".join(baseurl) + self.vlinks[i] + \
'?su=' + self.uid + \
'&qyid=' + uuid4().hex + \
'&client=&z=&bt=&ct=&tn=' + str(randint(10000,20000))
self.urls.append(url)

if options & moonplayer.OPT_DOWNLOAD:
moonplayer.download(result, result[0])
# Get final urls
self.result = []
moonplayer.get_url(self.urls[0], self.parse_final_url, options)

def parse_final_url(self, content, options):
i = len(self.result) / 2
self.result.append('%s_%i.mp4' % (self.name, i))
self.result.append(str(json.loads(content)['l']))
i += 1
if i < len(self.urls): # Parse next final url
moonplayer.get_url(self.urls[i], self.parse_final_url, options)
elif options & moonplayer.OPT_DOWNLOAD:
moonplayer.download(self.result, self.name + '.mp4')
else:
if len(self.urls) > 2:
moonplayer.warn('本视频较长,爱奇艺视频地址10分钟变化一次,建议下载后播放,避免播放到一半时下载地址失效!')
moonplayer.play(result)
moonplayer.play(self.result)

parser = Parser()

aw_re = re.compile(r'<a .*?href="(http://www.iqiyi.com/[vw]_.+?)".*?>([^<>]+)</a>')
def parse_a_cb(content, data):
result = []
match = aw_re.search(content)
while match:
result.extend(match.group(2, 1))
match = aw_re.search(content, match.end(0))
moonplayer.show_album(result)

## Parse tv series /movies
def parse_tv_cb(content, data):
result = list_links(content, 'http://www.iqiyi.com/dian')
result += list_links(content, 'http://www.iqiyi.com/v_')
moonplayer.show_album(result)
27 changes: 19 additions & 8 deletions rpms/SOURCES/moonplayer/plugin_sohu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@
import moonplayer

## hosts
hosts = ('tv.sohu.com',)
hosts = ('tv.sohu.com', 'my.tv.sohu.com')

##--------##
## search ##
##--------##
def search(kw, page):
url = 'http://so.tv.sohu.com/mts?box=1&wd=' + kw + '&p=' + str(page)
kw = kw.replace(' ', '+')
url = 'http://so.tv.sohu.com/mts?c=0&v=0&length=0&limit=0&o=0&st=&wd=' + kw + '&p=' + str(page)
moonplayer.get_url(url, search_cb, kw)

def search_cb(page, kw):
page = convert_to_utf8(page)
#tv series
links = list_links(page, 'http://so.tv.sohu.com/show/', kw)
links += list_links(page, 'http://tv.sohu.com/item/', kw)
links = list_links(page, 'http://so.tv.sohu.com/show/')
links += list_links(page, 'http://tv.sohu.com/item/')
n_series = len(links) / 2
#movies
links += list_links(page, 'http://tv.sohu.com/2', kw)
links += list_links(page, 'http://tv.sohu.com/2')
n = len(links) / 2
#others
links += list_links(page, 'http://my.tv.sohu.com/us/', kw)
links += list_links(page, 'http://my.tv.sohu.com/us/')
links += list_links(page, 'http://my.tv.sohu.com/pl/')
#show
moonplayer.show_list(links)
for i in xrange(n_series):
Expand Down Expand Up @@ -103,10 +105,14 @@ def parse_cb2(page, msg):
su = data[u'su']
ip = page[u'allot']
name = data[u'tvName'].encode('UTF-8')
tvid = page[u'tvid']
files = [s.replace('http://data.vod.itc.cn', '') for s in data[u'clipsURL']]
result = []
i = 0
#make cdnlist
cdnlist = ['http://%s/cdnList?new=%s&vid=%s' % (ip, new, vid) for new in su]
cdnlist = []
for i in xrange(len(su)):
cdnlist.append('http://%s/yp2p?prot=9&prod=flash&pt=1&file=%s&new=%s&vid=%s&tvid=%s' % (ip, files[i], su[i], vid, tvid))
data = {'result': [], 'cdnlist': cdnlist, 'name': name, 'options': msg[2]}
moonplayer.get_url(cdnlist[0], parse_cdnlist, data)

Expand Down Expand Up @@ -137,11 +143,15 @@ def parse_my_cb(page, msg):
vid = msg[0]
su = data[u'su']
ip = page[u'allot']
tvid = page[u'tvid']
name = data[u'tvName'].encode('UTF-8')
files = [s.replace('http://data.vod.itc.cn', '') for s in data[u'clipsURL']]
result = []
i = 0
#make cdnlist
cdnlist = ['http://%s/cdnList?new=%s&vid=%s' % (ip, new, vid) for new in su]
cdnlist = []
for i in xrange(len(su)):
cdnlist.append('http://%s/yp2p?prot=9&prod=flash&pt=1&file=%s&new=%s&vid=%s&tvid=%s' % (ip, files[i], su[i], vid, tvid))
data = {'result': [], 'cdnlist': cdnlist, 'name': name, 'options': msg[1]}
moonplayer.get_url(cdnlist[0], parse_cdnlist, data)

Expand All @@ -152,6 +162,7 @@ def parse_cdnlist(page, data):
i = len(result) / 2
result.append(data['name'] + '_' + str(i) + '.mp4')
result.append(url)
i += 1
if i < len(cdnlist):
moonplayer.get_url(cdnlist[i], parse_cdnlist, data)
elif data['options'] & moonplayer.OPT_DOWNLOAD:
Expand Down
16 changes: 10 additions & 6 deletions rpms/SPECS/moonplayer/moonplayer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
%global repo %{project}

# commit
%global _commit c05205092e8c57f975c33bd2829875f89e83e290
%global _commit bbf096ece7d451bbfa0b0a2b38a955e4d1f938ac
%global _shortcommit %(c=%{_commit}; echo ${c:0:7})

Name: moonplayer
Version: 0.34
Version: 0.49
Release: 1.git%{_shortcommit}%{?dist}
Summary: Video player that can play online videos
Summary(zh_CN): 一款可点播优酷, 土豆等网站在线视频的视频播放器
Expand All @@ -23,9 +23,9 @@ Source2: plugin_funshion.py
Source3: plugin_iqiyi.py
Source4: plugin_sohu.py

BuildRequires: qt-devel
#BuildRequires: qt-devel
BuildRequires: python-devel
#BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qtbase-devel
Requires: mplayer
Requires: mencoder

Expand All @@ -42,7 +42,7 @@ Video player that can play online videos from youku, tudou etc.
#export CPATH="%%{_includedir}/qt5/QtWidgets:$CPATH"
mkdir src/build
pushd src/build
%{_qt4_qmake} ..
%{_qt5_qmake} ..
make %{?_smp_mflags}
popd

Expand All @@ -57,13 +57,17 @@ install -m 0644 %{S:4} %{buildroot}%{_datadir}/%{name}/plugins/

%files
%defattr(-,root,root,-)
%doc README.md LICENSE
%doc README.md
%license LICENSE
%{_bindir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/%{name}.png

%changelog
* Sun Dec 6 2015 mosquito <[email protected]> - 0.49-1.gitbbf096e
- Update version to 0.49-1.gitbbf096e

* Wed Jul 15 2015 mosquito <[email protected]> - 0.34-1.gitc052050
- Update version to 0.34-1.gitc052050

Expand Down

0 comments on commit aa4dc34

Please sign in to comment.