zoukankan      html  css  js  c++  java
  • Linux Shell获取CCTV5节目单

    #!/bin/bash
    #查询CCTV5节目表
    
    <<'COMMENT'
    API:
    https://api.cntv.cn/epg/epginfo?serviceId=tvcctv&c=cctv5&d=20210617&cb=abccctv5&t=jsonp
    https://api.cntv.cn/epg/epglist?serviceId=channel&t=jsonp&c=cctv5&cb=tv_box3
    
    COMMENT
    
    jsonp="abccctv5"
    epgURL="https://api.cntv.cn/epg/epginfo?serviceId=tvcctv&c=cctv5&d=%date%&cb=abccctv5&t=jsonp"
    if [ $# -eq 1 ] && [[ "${1,,}" == "n" ]]
    then
    	today=$(date +"%Y%m%d" -d '+1 day')
    else
    	today=$(date +"%Y%m%d")
    fi
    
    jsonData=$(curl -sSfL ${epgURL//%date%/$today}|sed -r "s/^${jsonp}(//;s/);?$//")
    
    echo "$jsonData"|jq -r '.cctv5.program[]|.showTime+"	"+.t'
    


    附:获取CCTV5+节目表代码同理:

    #!/bin/bash
    #查询CCTV5+节目表
    
    <<'COMMENT'
    API:
    https://api.cntv.cn/epg/epginfo?serviceId=tvcctv&c=cctv5plus&d=20210617&cb=abccctv5plus&t=jsonp
    https://api.cntv.cn/epg/epglist?serviceId=channel&t=jsonp&c=cctv5plus&cb=tv_box3
    
    COMMENT
    
    jsonp="abccctv5plus"
    epgURL="https://api.cntv.cn/epg/epginfo?serviceId=tvcctv&c=cctv5plus&d=%date%&cb=abccctv5plus&t=jsonp"
    if [ $# -eq 1 ] && [[ "${1,,}" == "n" ]]
    then
    	today=$(date +"%Y%m%d" -d '+1 day')
    else
    	today=$(date +"%Y%m%d")
    fi
    
    jsonData=$(curl -sSfL ${epgURL//%date%/$today}|sed -r "s/^${jsonp}(//;s/);?$//")
    
    echo "$jsonData"|jq -r '.cctv5plus.program[]|.showTime+"	"+.t'
    

    本文来自博客园,作者:晴云孤魂,转载请注明原文链接:https://www.cnblogs.com/cnhack/p/14897994.html

  • 相关阅读:
    Pythonday01
    PYTHON_DAY2
    PYTHON_DAY3
    数据字典生成SQL语句
    Spring cloud Netflix >readMe
    SecureCRT的安装与激活
    MyBatis映射文件UserMapper.xml(mysql环境)
    数据库模糊查询4种用法
    MyBatis配置文件myBatisconfig.xml
    计算机基础:2进制和2进制算法。
  • 原文地址:https://www.cnblogs.com/cnhack/p/14897994.html
Copyright © 2011-2022 走看看