Git Product home page Git Product logo

Comments (1)

zhangqweb avatar zhangqweb commented on May 18, 2024 1

get_douyin_stream_data方法改下抓取就可以

spider.py

   req = urllib.request.Request(url, headers=headers)
   response = opener.open(req, timeout=15)
   html_str = response.read().decode('utf-8').replace('\\', '')  

    status = re.findall('"status":(.*?),', html_str)[0]
    nickname = re.findall('"nickname":"(.*?)",', html_str)[0]
     
    if status == "4":
        return  {"status":4,"nickname":nickname} 

    json_str = re.findall('web_stream_url":(.*?)},"emojiList', html_str)[0]  
    json_data = json.loads(json_str.replace(r'u0026', r'&'))  
    json_data['nickname'] = nickname
    json_data['status'] = status
    return json_data

main.py

def get_douyin_stream_url(json_data):
    # TODO: 获取抖音直播源地址
    nickname = json_data["nickname"]
    status = 4
    status = json_data["status"]  # 直播状态2是正在直播.4是未开播 

    if status == 4:
        data = [nickname, False, '', '']
    else:
       
        # flv视频流链接
        flv_url_list = json_data['flv_pull_url']
        # m3u8视频流链接
        m3u8_url_list = json_data['hls_pull_url_map']

        # origin蓝光1080P、720超清hd、720高清sd、540标清ld
        if video_quality == "原画" or video_quality == "蓝光":
            m3u8_url = m3u8_url_list["FULL_HD1"]
            flv_url = flv_url_list["FULL_HD1"]
        elif video_quality == "超清":
            m3u8_url = m3u8_url_list["HD1"]
            flv_url = flv_url_list["HD1"]
        elif video_quality == "高清":
            m3u8_url = m3u8_url_list["SD1"]
            flv_url = flv_url_list["SD1"]
        elif video_quality == "标清":
            m3u8_url = m3u8_url_list["SD2"]
            flv_url = flv_url_list["SD2"]

        data = [nickname, True, m3u8_url, flv_url]
    return data

from douyinliverecorder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.