Пример #1
0
def get_signin_vcode(cookie, codeString):
    url = ''.join([
        PASSPORT_BASE,
        'cgi-bin/genimage?',
        codeString,
    ])
    headers = {
        'Referer': REFERER,
    }

    headers_merged = default_headers.copy()
    #merge the headers
    for key in headers.keys():
        headers_merged[key] = headers[key]
    req = requests.get(url,
                       headers=headers_merged,
                       cookies=cookie,
                       timeout=50,
                       verify=False)
    #vcode_data is bytes
    vcode_data = req.content
    if vcode_data:
        vcode_path = os.path.join(utils.data_dir(), 'vcode.png')
        with open(vcode_path, 'wb') as fh:
            fh.write(vcode_data)

    return vcode_path
Пример #2
0
def playlist_path(pcs_file_path, stream):
    user_info = get_user_info()
    user_name = user_info['username']
    user_cookie = user_info['cookie']
    user_tokens = user_info['tokens']

    if stream:
        playlist_data = pcs.get_streaming_playlist(user_cookie, pcs_file_path,
                                                   stream)
        if playlist_data:
            raw_dir = os.path.dirname(pcs_file_path)
            m = re.search('\/(.*)', raw_dir)
            dirname = m.group(1)
            basename = os.path.basename(pcs_file_path)
            r = re.search('(.*)\.(.*)$', basename)
            filename = ''.join([r.group(1), stream, '.m3u8'])
            dirpath = os.path.join(utils.data_dir(), user_name, dirname)
            if not xbmcvfs.exists(dirpath):
                xbmcvfs.mkdirs(dirpath)
            filepath = os.path.join(dirpath, filename)
            tmpFile = xbmcvfs.File(filepath, 'w')
            tmpFile.write(bytearray(playlist_data, 'utf-8'))
            return filepath
        else:
            dialog.notification('', u'无法打开视频', xbmcgui.NOTIFICATION_INFO, 4000)
            return None
    else:
        url = pcs.stream_download(user_cookie, user_tokens, pcs_file_path)
        if url:
            return url
        else:
            dialog.notification('', u'无法打开原画,请尝试流畅模式',
                                xbmcgui.NOTIFICATION_INFO, 4000)
            return None
Пример #3
0
def playlist_path(pcs_file_path, stream):
    user_info = get_user_info()
    user_name = user_info['username']
    user_cookie = user_info['cookie']
    user_tokens = user_info['tokens']

    if stream:
        playlist_data = pcs.get_streaming_playlist(user_cookie, pcs_file_path, stream)
        if playlist_data:
            raw_dir = os.path.dirname(pcs_file_path)
            m = re.search('\/(.*)', raw_dir)
            dirname = m.group(1)
            basename = os.path.basename(pcs_file_path)
            r = re.search('(.*)\.(.*)$', basename)
            filename = ''.join([r.group(1), stream, '.m3u8'])
            dirpath = os.path.join(utils.data_dir(), user_name, dirname)
            if not xbmcvfs.exists(dirpath):
                xbmcvfs.mkdirs(dirpath)
            filepath = os.path.join(dirpath, filename)
            tmpFile = xbmcvfs.File(filepath, 'w')
            tmpFile.write(bytearray(playlist_data, 'utf-8'))
            return filepath
        else:
            dialog.notification('', u'无法打开视频,请尝试其他清晰度', xbmcgui.NOTIFICATION_INFO, 6000)
            return None
    else:
        url = pcs.get_download_link(user_cookie, user_tokens, pcs_file_path)
        return url
Пример #4
0
def playlist_path(pcs_file_path, stream):
    user_info = get_user_info()
    user_name = user_info['username']
    user_cookie = user_info['cookie']
    user_tokens = user_info['tokens']

    if stream:
        playlist_data = pcs.get_streaming_playlist(user_cookie, pcs_file_path, stream)
        if playlist_data:
            raw_dir = os.path.dirname(pcs_file_path)
            m = re.search('\/(.*)', raw_dir)
            dirname = m.group(1)
            basename = os.path.basename(pcs_file_path)
            r = re.search('(.*)\.(.*)$', basename)
            filename = ''.join([r.group(1), stream, '.m3u8'])
            dirpath = os.path.join(utils.data_dir(), user_name, dirname)
            if not xbmcvfs.exists(dirpath):
                xbmcvfs.mkdir(dirpath)
            filepath = os.path.join(dirpath, filename)
            with open(filepath, 'w') as f:
                f.write(playlist_data)
            return filepath
        else:
            return None
    else:
        url = pcs.get_download_link(user_cookie, user_tokens, pcs_file_path)
        return url
Пример #5
0
def get_signin_vcode(cookie, codeString):
        url=''.join([
                        PASSPORT_BASE,
                        'cgi-bin/genimage?',
                        codeString,
                    ])
        headers={'Referer':REFERER,}

        headers_merged = default_headers.copy()
        #merge the headers
        for key in headers.keys():
            headers_merged[key] = headers[key]
        req=requests.get(url, headers=headers_merged, cookies=cookie, timeout=50)
        #vcode_data is bytes
        vcode_data=req.content
        if vcode_data:
            vcode_path = os.path.join(utils.data_dir(), 'vcode.png')
            with open(vcode_path, 'wb') as fh:
                fh.write(vcode_data)

        return vcode_path