Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

能否支持使用season_id自动获取epidlist自动封禁旗下相关视频 #45

Open
Sayuri-Misaki opened this issue Oct 20, 2023 · 1 comment

Comments

@Sayuri-Misaki
Copy link

可采用https://api.bilibili.com/pgc/web/season/section?season_id=

例如
season_id:45838 为天宫赐福第二季
可直接找到相关的正片和PV等

https://www.bilibili.com/bangumi/media/md20340706/中的作品详情中的正片和PV花絮
为了避免格式问题,找到间谍过家家为例
https://www.bilibili.com/bangumi/media/md28237178
进行比对,可见依旧完结的番剧中格式也没有明显变化,即为固定格式
如何查找season_id?
可在https://www.bilibili.com/bangumi/media/md28237178中使用F12中的网络项
查询https://api.bilibili.com/pgc/web/season即可找到
https://api.bilibili.com/pgc/web/season?season_id=xxxxxx

function getEpidList($url) {
    // 获取JSON数据
    $jsonData = file_get_contents($url);
    // 将JSON数据解码为关联数组
    $data = json_decode($jsonData, true);
    // 如果 json中的code为-404 则返回null
    if ($data['code'] == -404) {
        return null;
    }
    if ($data !== null) {
        $epids = array();
        // 处理主要节目即正片(main_section)的剧集
        foreach ($data['result']['main_section']['episodes'] as $episode) {
            $share_url = $episode['share_url'];
            // 使用正则表达式从分享链接中提取EPID
            if (preg_match('/ep(\d+)/', $share_url, $matches)) {
                $epid = $matches[1];
                $epids[] = $epid;
            }
        }
        // 处理其他节目部分即PV或者其他
        foreach ($data['result']['section'] as $section) {
            foreach ($section['episodes'] as $episode) {
                $share_url = $episode['share_url'];
                // 使用正则表达式从分享链接中提取EPID
                if (preg_match('/ep(\d+)/', $share_url, $matches)) {
                    $epid = $matches[1];
                    $epids[] = $epid;
                }
            }
        }
        return $epids;
    } else {
        return null;
    }
}
$url = 'https://api.bilibili.com/pgc/web/season/section?season_id=' . $season_id;
$epid_list = getEpidList($url);
@david082321
Copy link
Owner

有几个技术细节需要解决:

  1. 每次用户请求 playurl ,服务器都要多一次这种请求,我觉得不太行,得加个缓存,并且只允许开了缓存设置的服务器。
  2. 我看了一下目前的数据库,应该没有适合的 table,要再创建一个。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants