├── .gitattributes ├── json ├── bilibiliAcconut.php ├── GetMovieData.php ├── classMovie.php ├── GetAnimeData.php ├── classAnime.php ├── images │ └── loading.svg └── css │ └── col.min.css ├── LICENSE ├── README.md ├── page-movie.php └── page-anime.php /.gitattributes: -------------------------------------------------------------------------------- 1 | *.css linguist-language=php -------------------------------------------------------------------------------- /json/bilibiliAcconut.php: -------------------------------------------------------------------------------- 1 | total; // 追剧总数 17 | $total_page = intdiv($total, $limit); // 分页总数 18 | $pagenum = $page * $limit; // 第一页为 page = 0 19 | 20 | // 构造请求接口 21 | for ($i = 0; $i < $total; $i++) { 22 | // limit 23 | if ($i == $limit || $biliM->season_id[$pagenum] == NULL) { 24 | break; 25 | } 26 | $array[$i]['num'] = $i; 27 | $array[$i]['title'] = $biliM->title[$pagenum]; 28 | $array[$i]['image_url'] = $biliM->image_url[$pagenum]; 29 | $array[$i]['evaluate'] = $biliM->evaluate[$pagenum]; 30 | $array[$i]['id'] = $biliM->season_id[$pagenum]; 31 | $pagenum++; 32 | } 33 | echo '{"total": ' . $total . ',"total_page": ' . $total_page . ', "limit": ' . $limit . ', "page": ' . $page . ', "data":' . json_encode($array, true) . '}'; 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 雾时之森 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /json/classMovie.php: -------------------------------------------------------------------------------- 1 | total = $this->getpage($uid); 21 | for ($i = 1; $i <= ceil($this->total / 15); $i++) { 22 | $url = "https://api.bilibili.com/x/space/bangumi/follow/list?type=2&follow_status=0&pn=$i&ps=15&vmid=$uid"; 23 | $info = json_decode(file_get_contents($url), true); 24 | foreach ($info['data']['list'] as $data) { 25 | array_push($this->title, $data['title']); 26 | array_push($this->image_url, str_replace('http://', '//', $data['cover'])); // 协议跟随 27 | array_push($this->evaluate, $data['evaluate']); 28 | array_push($this->season_id, $data['season_id']); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress B站追番/追剧页面模板 2 | 3 | ### 本项目为 [bilibili](https://github.com/TaylorLottner) 的二开,已获原作者授权! 4 | 注意:理论适用所有主题,但我只做了 Sakura 主题的 CSS 适配,其他主题请自行适配吧~ 5 | 6 | ### 使用说明 7 | 1. 下载本项目,将 `json` 整个目录扔到你的站点根路径,将 `page-anime.php` 和 `page-movie.php` 文件放到你的主题根路径。 8 | 9 | 2. 按照注释,修改 `json` 里的 `bilibiliAcconut.php` 文件,填入你的信息(参考下方获取你的信息)。 10 | !{}(https://view.amogu.cn/images/2020/08/26/20200528153655.jpg) 11 | 12 | 3. 最后在 WP后台 新建页面时选择相应的模板,创建页面即可。 13 | 14 | ### 获取信息 15 | #### 1. 获取B站UID 16 | 打开[](https://www.bilibili.com/),登入后进入个人空间,红框处为你的 UID,不要忘记把番剧设置成公开哦~ 17 | 18 |  19 | 20 | #### 2. 获取Cookie 21 | 登入后进入个人空间,按 **F12** 进入浏览器调试工具,打开 `Network` 再次刷新页面,找到与你 UID 相同的链接并打开,找到 `cookie` 一栏,**为了省事就完全复制**,每个人的 Cookie 都不一样,建议用浏览器的 **无痕模式** 操作,这里用谷歌浏览器演示,如下图: 22 | 23 |  24 | 25 | 举例(长度可能不一样):`_uuid=XXXXXXX-XXXX-XXXX-XXXX-82C16AFEC65E68468infoc; buvid3=8A0CA4AF-XXXX-XXXX-XXXX-8357010EB5F3155827infoc; sid=iwqx36hz; DedeUserID=8142789; DedeUserID__ckMd5=02832b48fef34f47; SESSDATA=fed39455%2C1606203773%2C8731e*51; bili_jct=58ba9ab942399022c6d85195c26f15e3` 26 | 27 | ### 补充 28 | 得知B站的防盗链根据 `referrer` 来判断请求是不是来自B站,那好办了在 head 中添加一行代码,把 `referrer` 去掉就行【加在追番模版的 `get_header(); ?>` 下面就行了,我的修改版已经添加】 29 | 30 | ```html 31 | 32 | ``` 33 | 34 | ### 预览 35 | 36 |  37 | -------------------------------------------------------------------------------- /json/GetAnimeData.php: -------------------------------------------------------------------------------- 1 | total; // 追番总数 17 | $total_page = intdiv($total, $limit); // 分页总数 18 | $pagenum = $page * $limit; // 第一页为 page = 0 19 | 20 | // 观看进度 21 | function progress($str1, $str2) 22 | { 23 | if (is_numeric($str1) && is_numeric($str2) && $str1 == $str2) { 24 | return "已经追完了咯~"; 25 | } elseif (is_numeric($str1) && is_numeric($str2)) { 26 | return "第" . $str1 . "话/共" . $str2 . "话"; 27 | } elseif (is_numeric($str1) && !is_numeric($str2)) { 28 | return "第" . $str1 . "话/" . $str2; 29 | } elseif ($str2 == "还没开始更新呢~") { 30 | return $str2; 31 | } else { 32 | return $str1; 33 | } 34 | } 35 | // 观看进度条 36 | function progress_bar($str1, $str2) 37 | { 38 | if (is_numeric($str1) && is_numeric($str2)) { 39 | return ($str1 / $str2 * 100) . "%"; 40 | } elseif ($str1 == "貌似还没有看呢~" || $str2 == "还没开始更新呢~") { 41 | return "0%"; 42 | } else { 43 | return "100%"; 44 | } 45 | } 46 | 47 | // 构造请求接口 48 | for ($i = 0; $i < $total; $i++) { 49 | // limit 50 | if ($i == $limit || $biliA->season_id[$pagenum] == NULL) { 51 | break; 52 | } 53 | $array[$i]['num'] = $i; 54 | $array[$i]['title'] = $biliA->title[$pagenum]; 55 | $array[$i]['image_url'] = $biliA->image_url[$pagenum]; 56 | $array[$i]['evaluate'] = $biliA->evaluate[$pagenum]; 57 | $array[$i]['id'] = $biliA->season_id[$pagenum]; 58 | $array[$i]['progress'] = progress($biliA->progress[$pagenum], $biliA->fan_number[$pagenum]); 59 | $array[$i]['progress_bar'] = progress_bar($biliA->progress[$pagenum], $biliA->fan_number[$pagenum]); 60 | $pagenum++; 61 | } 62 | echo '{"total": ' . $total . ',"total_page": ' . $total_page . ', "limit": ' . $limit . ', "page": ' . $page . ', "data":' . json_encode($array, true) . '}'; 63 | -------------------------------------------------------------------------------- /json/classAnime.php: -------------------------------------------------------------------------------- 1 | total = $this->getpage($uid); 48 | for ($i = 1; $i <= ceil($this->total / 15); $i++) { 49 | $url = "https://api.bilibili.com/x/space/bangumi/follow/list?type=1&follow_status=0&pn=$i&ps=15&vmid=$uid"; 50 | $ch = curl_init(); // 初始化curl模块 51 | curl_setopt($ch, CURLOPT_URL, $url); // 登录提交的地址 52 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取到的数据以文件流的方式返回 53 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( // 发送请求头 54 | "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36", 55 | "Referer: https://www.bilibili.com/", 56 | "Cookie: $cookie", 57 | )); 58 | $info = json_decode(curl_exec($ch), true); 59 | curl_close($ch); // 关闭连接 60 | foreach ($info['data']['list'] as $data) { 61 | array_push($this->title, $data['title']); 62 | array_push($this->image_url, str_replace('http://', '//', $data['cover'])); // 协议跟随 63 | array_push($this->fan_number, $this->fan_number($data['new_ep']['title'])); 64 | array_push($this->progress, $this->process($data['progress'])); 65 | array_push($this->evaluate, $data['evaluate']); 66 | array_push($this->season_id, $data['season_id']); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /json/images/loading.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /page-movie.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 137 |