mirror of
https://github.com/soimort/you-get.git
synced 2025-01-24 22:15:03 +03:00
[UCAS] use http.client instead of requests
This commit is contained in:
parent
d0431d8bd6
commit
c7a262cf65
@ -4,14 +4,14 @@ __all__ = ['ucas_download', 'ucas_download_single', 'ucas_download_playlist']
|
|||||||
|
|
||||||
from ..common import *
|
from ..common import *
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import requests
|
import http.client
|
||||||
from time import time
|
from time import time
|
||||||
from random import random
|
from random import random
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Do not replace request.get with get_content
|
Do not replace http.client with get_content
|
||||||
for UCAS's server is not correctly returning data!
|
for UCAS's server is not correctly returning data!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -39,31 +39,32 @@ def _get_video_query_url(resourceID):
|
|||||||
'Referer': 'http://v.ucas.ac.cn/',
|
'Referer': 'http://v.ucas.ac.cn/',
|
||||||
'Connection': 'keep-alive',
|
'Connection': 'keep-alive',
|
||||||
}
|
}
|
||||||
params = (
|
conn = http.client.HTTPConnection("210.76.211.10")
|
||||||
('method', 'query'),
|
|
||||||
('loginname', 'videocas'),
|
conn.request("GET", "/vplus/remote.do?method=query2&loginname=videocas&pwd=af1c7a4c5f77f790722f7cae474c37e281203765d423a23b&resource=%5B%7B%22resourceID%22%3A%22" + resourceID + "%22%2C%22on%22%3A1%2C%22time%22%3A600%2C%22eid%22%3A100%2C%22w%22%3A800%2C%22h%22%3A600%7D%5D&timeStamp=" + str(int(time())), headers=headers)
|
||||||
('pwd', 'af1c7a4c5f77f790722f7cae474c37e281203765d423a23b'),
|
res = conn.getresponse()
|
||||||
('resource', '[{"resourceID":"' + resourceID + '","on":1,"time":60000,"eid":100,"w":800,"h":600}]'),
|
data = res.read()
|
||||||
('timeStamp', '{timeStamp}'.format(timeStamp = int(time()))),
|
|
||||||
)
|
info = data.decode("utf-8")
|
||||||
a = requests.get('http://210.76.211.10/vplus/remote.do', headers=headers, params=params)
|
|
||||||
info = a.content.decode('utf-8')
|
|
||||||
return match1(info, r'video":"(.+)"')
|
return match1(info, r'video":"(.+)"')
|
||||||
|
|
||||||
def _get_virtualPath(video_query_url):
|
def _get_virtualPath(video_query_url):
|
||||||
#getResourceJsCode2
|
#getResourceJsCode2
|
||||||
html = requests.get(video_query_url)
|
html = get_content(video_query_url)
|
||||||
html = html.content.decode('utf-8')
|
|
||||||
|
|
||||||
return match1(html, r"function\s+getVirtualPath\(\)\s+{\s+return\s+'(\w+)'")
|
return match1(html, r"function\s+getVirtualPath\(\)\s+{\s+return\s+'(\w+)'")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _get_video_list(resourceID):
|
def _get_video_list(resourceID):
|
||||||
""""""
|
""""""
|
||||||
video_xml = requests.get('http://210.76.211.10/vplus/member/resource.do?isyulan=0&method=queryFlashXmlByResourceId&resourceId={resourceID}&randoms={randoms}'.format(resourceID = resourceID,
|
conn = http.client.HTTPConnection("210.76.211.10")
|
||||||
randoms = random()))
|
|
||||||
video_xml = video_xml.content.decode('utf-8')
|
conn.request("GET", '/vplus/member/resource.do?isyulan=0&method=queryFlashXmlByResourceId&resourceId={resourceID}&randoms={randoms}'.format(resourceID = resourceID,
|
||||||
|
randoms = random()))
|
||||||
|
res = conn.getresponse()
|
||||||
|
data = res.read()
|
||||||
|
|
||||||
|
video_xml = data.decode("utf-8")
|
||||||
|
|
||||||
root = ET.fromstring(video_xml.split('___!!!___')[0])
|
root = ET.fromstring(video_xml.split('___!!!___')[0])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user