├── .gitattributes ├── LICENSE ├── README.md ├── json ├── GetAnimeData.php ├── GetMovieData.php ├── bilibiliAcconut.php ├── classAnime.php ├── classMovie.php ├── css │ └── col.min.css └── images │ └── loading.svg ├── page-anime.php └── page-movie.php /.gitattributes: -------------------------------------------------------------------------------- 1 | *.css linguist-language=php -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | ![](https://view.amogu.cn/images/2020/08/26/20200528154041.jpg) 19 | 20 | #### 2. 获取Cookie 21 | 登入后进入个人空间,按 **F12** 进入浏览器调试工具,打开 `Network` 再次刷新页面,找到与你 UID 相同的链接并打开,找到 `cookie` 一栏,**为了省事就完全复制**,每个人的 Cookie 都不一样,建议用浏览器的 **无痕模式** 操作,这里用谷歌浏览器演示,如下图: 22 | 23 | ![](https://view.amogu.cn/images/2020/08/26/20200528154355.png) 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 | ![](https://view.amogu.cn/images/2020/08/26/H8b85865e4ca0489cb0542c2358526f05i.jpg) 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/GetMovieData.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 | -------------------------------------------------------------------------------- /json/bilibiliAcconut.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/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 | -------------------------------------------------------------------------------- /json/css/col.min.css: -------------------------------------------------------------------------------- 1 | @charset 'utf-8'; 2 | /* 3 | * The column 4 | * Author: Bootstrap 5 | * Modifier: Eltrac 6 | * License: MIT 7 | */ 8 | .container{width:100%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}@media (min-width:576px){.container{max-width:540px}}@media (min-width:768px){.container{max-width:720px}}@media (min-width:992px){.container{max-width:960px}}@media (min-width:1200px){.container{max-width:1140px}}.container-fluid{width:100%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.row{display:flex;flex-wrap:wrap;margin-right:-15px;margin-left:-15px}.no-gutters{margin-right:0;margin-left:0}.no-gutters>.col,.no-gutters>[class*=col-]{padding-right:0;padding-left:0}.col,.col-1,.col-10,.col-11,.col-12,.col-2,.col-3,.col-4,.col-5,.col-6,.col-7,.col-8,.col-9,.col-auto,.col-lg,.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-auto,.col-md,.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-auto,.col-sm,.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-auto,.col-xl,.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-auto{position:relative;width:100%;padding-right:15px;padding-left:15px}.col{flex-basis:0;flex-grow:1;max-width:100%}.col-auto{flex:0 0 auto;width:auto;max-width:100%}.col-1{flex:0 0 8.333333%;max-width:8.333333%}.col-2{flex:0 0 16.666667%;max-width:16.666667%}.col-3{flex:0 0 25%;max-width:25%}.col-4{flex:0 0 33.333333%;max-width:33.333333%}.col-5{flex:0 0 41.666667%;max-width:41.666667%}.col-6{flex:0 0 50%;max-width:50%}.col-7{flex:0 0 58.333333%;max-width:58.333333%}.col-8{flex:0 0 66.666667%;max-width:66.666667%}.col-9{flex:0 0 75%;max-width:75%}.col-10{flex:0 0 83.333333%;max-width:83.333333%}.col-11{flex:0 0 91.666667%;max-width:91.666667%}.col-12{flex:0 0 100%;max-width:100%}.order-first{order:-1}.order-last{order:13}.order-0{order:0}.order-1{order:1}.order-2{order:2}.order-3{order:3}.order-4{order:4}.order-5{order:5}.order-6{order:6}.order-7{order:7}.order-8{order:8}.order-9{order:9}.order-10{order:10}.order-11{order:11}.order-12{order:12}.offset-1{margin-left:8.333333%}.offset-2{margin-left:16.666667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.333333%}.offset-5{margin-left:41.666667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.333333%}.offset-8{margin-left:66.666667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.333333%}.offset-11{margin-left:91.666667%}@media (min-width:576px){.col-sm{flex-basis:0;flex-grow:1;max-width:100%}.col-sm-auto{flex:0 0 auto;width:auto;max-width:100%}.col-sm-1{flex:0 0 8.333333%;max-width:8.333333%}.col-sm-2{flex:0 0 16.666667%;max-width:16.666667%}.col-sm-3{flex:0 0 25%;max-width:25%}.col-sm-4{flex:0 0 33.333333%;max-width:33.333333%}.col-sm-5{flex:0 0 41.666667%;max-width:41.666667%}.col-sm-6{flex:0 0 50%;max-width:50%}.col-sm-7{flex:0 0 58.333333%;max-width:58.333333%}.col-sm-8{flex:0 0 66.666667%;max-width:66.666667%}.col-sm-9{flex:0 0 75%;max-width:75%}.col-sm-10{flex:0 0 83.333333%;max-width:83.333333%}.col-sm-11{flex:0 0 91.666667%;max-width:91.666667%}.col-sm-12{flex:0 0 100%;max-width:100%}.order-sm-first{order:-1}.order-sm-last{order:13}.order-sm-0{order:0}.order-sm-1{order:1}.order-sm-2{order:2}.order-sm-3{order:3}.order-sm-4{order:4}.order-sm-5{order:5}.order-sm-6{order:6}.order-sm-7{order:7}.order-sm-8{order:8}.order-sm-9{order:9}.order-sm-10{order:10}.order-sm-11{order:11}.order-sm-12{order:12}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.333333%}.offset-sm-2{margin-left:16.666667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.333333%}.offset-sm-5{margin-left:41.666667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.333333%}.offset-sm-8{margin-left:66.666667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.333333%}.offset-sm-11{margin-left:91.666667%}}@media (min-width:768px){.col-md{flex-basis:0;flex-grow:1;max-width:100%}.col-md-auto{flex:0 0 auto;width:auto;max-width:100%}.col-md-1{flex:0 0 8.333333%;max-width:8.333333%}.col-md-2{flex:0 0 16.666667%;max-width:16.666667%}.col-md-3{flex:0 0 25%;max-width:25%}.col-md-4{flex:0 0 33.333333%;max-width:33.333333%}.col-md-5{flex:0 0 41.666667%;max-width:41.666667%}.col-md-6{flex:0 0 50%;max-width:50%}.col-md-7{flex:0 0 58.333333%;max-width:58.333333%}.col-md-8{flex:0 0 66.666667%;max-width:66.666667%}.col-md-9{flex:0 0 75%;max-width:75%}.col-md-10{flex:0 0 83.333333%;max-width:83.333333%}.col-md-11{flex:0 0 91.666667%;max-width:91.666667%}.col-md-12{flex:0 0 100%;max-width:100%}.order-md-first{order:-1}.order-md-last{order:13}.order-md-0{order:0}.order-md-1{order:1}.order-md-2{order:2}.order-md-3{order:3}.order-md-4{order:4}.order-md-5{order:5}.order-md-6{order:6}.order-md-7{order:7}.order-md-8{order:8}.order-md-9{order:9}.order-md-10{order:10}.order-md-11{order:11}.order-md-12{order:12}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.333333%}.offset-md-2{margin-left:16.666667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.333333%}.offset-md-5{margin-left:41.666667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.333333%}.offset-md-8{margin-left:66.666667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.333333%}.offset-md-11{margin-left:91.666667%}}@media (min-width:992px){.col-lg{flex-basis:0;flex-grow:1;max-width:100%}.col-lg-auto{flex:0 0 auto;width:auto;max-width:100%}.col-lg-1{flex:0 0 8.333333%;max-width:8.333333%}.col-lg-2{flex:0 0 16.666667%;max-width:16.666667%}.col-lg-3{flex:0 0 25%;max-width:25%}.col-lg-4{flex:0 0 33.333333%;max-width:33.333333%}.col-lg-5{flex:0 0 41.666667%;max-width:41.666667%}.col-lg-6{flex:0 0 50%;max-width:50%}.col-lg-7{flex:0 0 58.333333%;max-width:58.333333%}.col-lg-8{flex:0 0 66.666667%;max-width:66.666667%}.col-lg-9{flex:0 0 75%;max-width:75%}.col-lg-10{flex:0 0 83.333333%;max-width:83.333333%}.col-lg-11{flex:0 0 91.666667%;max-width:91.666667%}.col-lg-12{flex:0 0 100%;max-width:100%}.order-lg-first{order:-1}.order-lg-last{order:13}.order-lg-0{order:0}.order-lg-1{order:1}.order-lg-2{order:2}.order-lg-3{order:3}.order-lg-4{order:4}.order-lg-5{order:5}.order-lg-6{order:6}.order-lg-7{order:7}.order-lg-8{order:8}.order-lg-9{order:9}.order-lg-10{order:10}.order-lg-11{order:11}.order-lg-12{order:12}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.333333%}.offset-lg-2{margin-left:16.666667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.333333%}.offset-lg-5{margin-left:41.666667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.333333%}.offset-lg-8{margin-left:66.666667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.333333%}.offset-lg-11{margin-left:91.666667%}}@media (min-width:1200px){.col-xl{flex-basis:0;flex-grow:1;max-width:100%}.col-xl-auto{flex:0 0 auto;width:auto;max-width:100%}.col-xl-1{flex:0 0 8.333333%;max-width:8.333333%}.col-xl-2{flex:0 0 16.666667%;max-width:16.666667%}.col-xl-3{flex:0 0 25%;max-width:25%}.col-xl-4{flex:0 0 33.333333%;max-width:33.333333%}.col-xl-5{flex:0 0 41.666667%;max-width:41.666667%}.col-xl-6{flex:0 0 50%;max-width:50%}.col-xl-7{flex:0 0 58.333333%;max-width:58.333333%}.col-xl-8{flex:0 0 66.666667%;max-width:66.666667%}.col-xl-9{flex:0 0 75%;max-width:75%}.col-xl-10{flex:0 0 83.333333%;max-width:83.333333%}.col-xl-11{flex:0 0 91.666667%;max-width:91.666667%}.col-xl-12{flex:0 0 100%;max-width:100%}.order-xl-first{order:-1}.order-xl-last{order:13}.order-xl-0{order:0}.order-xl-1{order:1}.order-xl-2{order:2}.order-xl-3{order:3}.order-xl-4{order:4}.order-xl-5{order:5}.order-xl-6{order:6}.order-xl-7{order:7}.order-xl-8{order:8}.order-xl-9{order:9}.order-xl-10{order:10}.order-xl-11{order:11}.order-xl-12{order:12}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.333333%}.offset-xl-2{margin-left:16.666667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.333333%}.offset-xl-5{margin-left:41.666667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.333333%}.offset-xl-8{margin-left:66.666667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.333333%}.offset-xl-11{margin-left:91.666667%}}.main-container{margin:0 auto}@media (min-width:576px){.main-container{max-width:540px}}@media (min-width:768px){.main-container{max-width:720px}}@media (min-width:992px){.main-container{max-width:940px}}@media (min-width:1200px){.main-container{max-width:960px}} -------------------------------------------------------------------------------- /json/images/loading.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /page-anime.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 147 |

我的追番 当前已追" . $sum['total'] . "部,继续加油!

. NEXT .
" 150 | ?> 151 | 152 | 155 | 156 | 201 | 202 | 9 | 10 | 11 | 12 | 137 |

我的追剧 当前已追" . $sum['total'] . "部,继续加油!

. NEXT .
" 140 | ?> 141 | 142 | 145 | 146 | 191 | 192 |