letvcloudchecker:批量查询乐视云视频情况,导出csv

https://github.com/cnbeining/letvcloudchecker
对付商业软件的最好办法就是你也写一个,效果更好,然后开源。
GPL v2。
代码下面。

 

#!/usr/bin/env python3
#coding:utf-8
# Author: Beining  --<ACICFG>
# Purpose: Batch check whether the Letvcloud file's statues.
# Created: 08/02/2014
import urllib.request
import sys
import os
import json
import hashlib
import getopt
global line_to_write
line_to_write = ''
#----------------------------------------------------------------------
def check_upload(source_id):
    """"""
    line_to_write_this =''
    message = ''
    user_id = ''
    video_name = ''
    video_duration = ''
    add_time = ''
    type_avalable = ''
    user_unique = ''
    video_type_set = ''
    str2Hash = 'cfflashformatjsonran0.7214574650861323uu2d8c027396ver2.1vu' + source_id + 'bie^#@(%27eib58'
    sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
    request_info = urllib.request.Request('http://api.letvcloud.com/gpc.php?&sign='+sign+'&cf=flash&vu='+source_id+'&ver=2.1&ran=0.7214574650861323&qr=2&format=json&uu=2d8c027396')
    try:
        response = urllib.request.urlopen(request_info)
        data = response.read()
        message = json.loads(data.decode('utf-8'))['message']
        user_id = json.loads(data.decode('utf-8'))['data']['video_info']['user_id']
        video_name = json.loads(data.decode('utf-8'))['data']['video_info']['video_name']
        video_duration = json.loads(data.decode('utf-8'))['data']['video_info']['video_duration']
        add_time = json.loads(data.decode('utf-8'))['data']['video_info']['add_time']
        user_unique = json.loads(data.decode('utf-8'))['data']['user_info']['user_unique']
        video_type_set = json.loads(data.decode('utf-8'))['data']['user_info']['video_type_set']
        for i in json.loads(data.decode('utf-8'))['data']['video_info']['media']:
            type_avalable = type_avalable + json.loads(data.decode('utf-8'))['data']['video_info']['media'][i]['video_type']
    except:
        return 'Cannot check '+source_id+' !'
    line_to_write_this = source_id + ',' + message + ',' + video_name + ',' + video_duration + ',' + add_time + ',' + user_id + ',' + type_avalable
    print(line_to_write_this)
    return line_to_write_this
#----------------------------------------------------------------------
def usage():
    """"""
    print('''Usage:
    python3 letvcheck.py (-h)( -s) vu1 vu2
    -s: Save to CSV file.
    -h: Help.''')
if __name__=='__main__':
    argv_list = []
    argv_list = sys.argv[1:]
    file_csv = ''
    line_to_write = ''
    try:
        opts, args = getopt.getopt(argv_list, "hs:", ["help",'save'])
    except getopt.GetoptError:
        usage()
        exit()
    for o, a in opts:
        if o in ('-h', '--help'):
            usage()
            exit()
        elif o in ('-s', '--save'):
            file_csv = a
            print('Saving your result to csv file '+a)
            try:
                argv_list.remove('-s')
            except:
                break
            argv_list.remove(a)
    #print(argv_list)
    if file_csv is not '':
        for vu in argv_list:
            line_to_write = line_to_write + str(check_upload(vu)) + '\n'
            line_to_write = line_to_write
            f = open(file_csv, "w")
            f.writelines(line_to_write)
            f.close()
    else:
        for vu in argv_list:
            check_upload(vu)

 

5 thoughts on “letvcloudchecker:批量查询乐视云视频情况,导出csv

  1. 我了个去羽

    beining好,
    我现在也在申请调用乐视api,但是
    第一,我申请不到他的key,不知道为啥,提交申请发送邮件很久都没人联系我。
    第二,我发现你调用的接口跟现在官方文档不同,现在他的ver还是2.0,你的已经到2.1了。。。。他默认接口地址统一为:http://api.letvcloud.com/open.php,跟你的参数也不同。。
    这个。。。。难道你是内部开发人员??

    Reply
    1. Beining Post author

      我肯定不是什么内部开发人员了。。。
      1.你恐怕需要交钱用乐视云视频才能给你这个Key。谁知道你会不会再开发个flvcd出来。。。
      2.我也发现了,版本号不一样。
      3.我是抓包取的,和open.php接口不是一个。

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *