Skip to content

Commit

Permalink
bug fix for iqiyi list loopback error
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Jan 15, 2018
1 parent c2ae65a commit efcca8e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
48 changes: 27 additions & 21 deletions wwqLyParse/parsers/iqiyilistparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,25 +324,26 @@ def parse(self, input_text, *k, **kk):
}

data_doc_id = html('span.play_source').attr('data-doc-id')
ejson_url = 'http://rq.video.iqiyi.com/aries/e.json?site=iqiyi&docId=' + data_doc_id + '&count=100000'
ejson = json.loads(get_url(ejson_url))
ejson_datas = ejson["data"]["objs"]
data["total"] = ejson_datas["info"]["total_video_number"]
data["title"] = ejson_datas["info"]["album_title"]
album_items = ejson_datas["episode"]["data"]
for album_item in album_items:
no = '第' + str(album_item["play_order"]) + '集'
name = album_item["title"]
url = album_item["play_url"]
subtitle = album_item["desciption"]
info = {
"name": name,
"no": no,
"subtitle": subtitle,
"url": url
}
data["data"].append(info)
# print(ejson)
if data_doc_id:
ejson_url = 'http://rq.video.iqiyi.com/aries/e.json?site=iqiyi&docId=' + data_doc_id + '&count=100000'
ejson = json.loads(get_url(ejson_url))
ejson_datas = ejson["data"]["objs"]
data["total"] = ejson_datas["info"]["total_video_number"]
data["title"] = ejson_datas["info"]["album_title"]
album_items = ejson_datas["episode"]["data"]
for album_item in album_items:
no = '第' + str(album_item["play_order"]) + '集'
name = album_item["title"]
url = album_item["play_url"]
subtitle = album_item["desciption"]
info = {
"name": name,
"no": no,
"subtitle": subtitle,
"url": url
}
data["data"].append(info)
# print(ejson)
return data


Expand Down Expand Up @@ -376,9 +377,10 @@ def parse(self, input_text, *k, **kk):
if type(item2) == dict and 'level' in item2 and \
item2['level'] == 3 and 'url' in item2:
url = item2['url']
if url:
break
if url and re.search(r"www.iqiyi.com/v_", url):
url = None
if url:
logging.debug(url)
break
except json.JSONDecodeError:
logging.exception("IQiYiVListParser Error")
Expand All @@ -396,7 +398,10 @@ def parse(self, input_text, *k, **kk):
item1['position'] == 3 and 'item' in item1:
if type(item1['item']) == dict and '@id' in item1['item']:
url = item1['item']['@id']
if url and re.search(r"www.iqiyi.com/v_", url):
url = None
if url:
logging.debug(url)
break
except json.JSONDecodeError:
logging.exception("IQiYiVListParser Error")
Expand All @@ -408,6 +413,7 @@ def parse(self, input_text, *k, **kk):
a = PyQuery(a)
url = a.attr("href")
if url:
logging.debug(url)
break
if url:
if str(url).startswith("//"):
Expand Down
1 change: 1 addition & 0 deletions wwqLyParse/parsers/yinyuetaiparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def parse(self, input_text, types=None, *k, **kk):
video_data = api_data['videoInfo']['coreVideoInfo']

title = video_data['videoName']
title = str(title).replace("<", "《").replace(">", "》")
artist = video_data['artistNames']
data["name"] = title
for s in video_data['videoUrlModels']:
Expand Down
4 changes: 3 additions & 1 deletion wwqLyParse/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
# main(r"file:///E:\QQDownloads\url.media")
# main(r"https://youku.pohaier.com/yk.php?url=d1BTTTFlVnRTell1VDhtQmlLZ3lrTkZSUGtTdlhrY3JOZlJOTnZZRmE2ZDZiSVNkNU9rdVJoMlBoL1doR1FDRGVmWkJCR25rbkE=")
# main("http://defaultts.tc.qq.com/defaultts.tc.qq.com/mcvctgljBW77YvaEtxIhsDu81rGkBDNrvJH-aOijrz6vYDOAERMwo8YjsMhsUX30gycp3l48NFvhiK0q8RrcI_piINVQwY4sfKdsmv5qi459Q7GV-rljooWl1yRZcP-f/c00248syj3f.321004.ts.m3u8?ver=4")
main("http://v.yinyuetai.com/video/2811002", parsers_name=["YinYueTaiParser"])
# main("http://v.yinyuetai.com/video/2796852", parsers_name=["YinYueTaiParser"])
# main("http://www.mgtv.com/b/316045/4096972.html", types="collection")
# main("http://www.mgtv.com/b/316045/4096972.html", parsers_name=["MgTVParser"])
# main("http://www.mgtv.com/b/316045/4096972.html", label="3@MgTVParser")
# url_cache.timeout = 10
main("http://www.iqiyi.com/v_19rrl8pmn8.html")
# main("http://www.iqiyi.com/lib/m_201087714.html")
# main("http://www.iqiyi.com/v_19rrl8pmn8.html")
# main("http://www.iqiyi.com/v_19rr8jbmeo.html", types="list")
# time.sleep(10)
# main("http://www.iqiyi.com/v_19rrl8pmn8.html", types="list")
Expand Down
2 changes: 1 addition & 1 deletion wwqLyParse/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.4
1.2.5

0 comments on commit efcca8e

Please sign in to comment.