Plugin Directory

Changeset 1534780


Ignore:
Timestamp:
11/16/2016 04:30:17 AM (9 years ago)
Author:
0xbbc
Message:

Extended support for bilibili param

Location:
dplayer-for-wp
Files:
2 edited
7 copied

Legend:

Unmodified
Added
Removed
  • dplayer-for-wp/tags/1.1.4/dplayer.php

    r1531408 r1534780  
    33* Plugin Name: DPlayer for WordPress
    44* Description: Wow, such a lovely HTML5 danmaku video player comes to WordPress
    5 * Version: 1.1.3
     5* Version: 1.1.4
    66* Author: 0xBBC
    77* Author URI: https://blog.0xbbc.com/
     
    4848    }
    4949   
     50    public static function dplayer_bilibili_url_handler($bilibili_url) {
     51        $aid = 0;
     52        $page = 1;
     53        $is_bilibili = false;
     54        if (preg_match('/^[\d]+$/', $bilibili_url)) {
     55            $aid = $bilibili_url;
     56            $is_bilibili = true;
     57        } else {
     58            $parsed = parse_url($bilibili_url);
     59            if ($parsed['host'] === 'www.bilibili.com') {
     60                preg_match('/^\/video\/av([\d]+)(?:\/index_([\d]+)\.html)?/', $parsed['path'], $path_match);
     61                if ($path_match) {
     62                    $is_bilibili = true;
     63                    $aid = $path_match[1];
     64                    $page = $path_match[2] == null ? 1 : $path_match[2];
     65                    preg_match('/^page=([\d]+)$/', $parsed['fragment'], $page_match);
     66                    if ($page_match) $page = $page_match[1];
     67                }
     68            }
     69        }
     70
     71        if ($is_bilibili) {
     72            if ($page == 1) {
     73                return array(get_option( 'kblog_danmaku_url', '' ).'bilibili?aid='.$aid);
     74            } else {
     75                $cid = -1;
     76                $json_response = @json_decode(gzdecode(file_get_contents('http://www.bilibili.com/widget/getPageList?aid='.$aid)), true);
     77                if ($json_response) {
     78                    foreach ($json_response as $page_info) {
     79                        if ($page_info['page'] == $page) {
     80                            $cid = $page_info['cid'];
     81                            break;
     82                        }
     83                    }
     84                }
     85               
     86                if ($cid != -1) {
     87                    return array(get_option( 'kblog_danmaku_url', '' ).'bilibili?cid='.$cid);
     88                }
     89            }
     90        }
     91        return null;
     92    }
     93   
    5094    public static function dplayer_load($atts = [], $content = null, $tag = '') {
    5195        // normalize attribute keys, lowercase
     
    88132            'api' => get_option( 'kblog_danmaku_url', '' ),
    89133        );
    90         if ($atts['bilibili']) $danmaku['addition'] = array(get_option( 'kblog_danmaku_url', '' ).'bilibili?aid='.$atts['bilibili']);
     134       
     135        if ($atts['bilibili']) $danmaku['addition'] = DPlayer::dplayer_bilibili_url_handler($atts['bilibili']);
    91136        $data['danmaku'] = ($atts['danmu'] != 'false') ? $danmaku : null;
    92137
  • dplayer-for-wp/tags/1.1.4/readme.txt

    r1531408 r1534780  
    44Requires at least: 3.0.1
    55Tested up to: 4.6.1
    6 Stable tag: 1.1.3
     6Stable tag: 1.1.4
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2323Parameter 'preload', preload mode, 'auto', 'metatdata' or 'none'. Optional and default metadata.
    2424Parameter 'hotkey', enable builtin hotkey? including left, right and Space. Optional and default true.
    25 Parameter 'bilibili', bilibili视频AV号. Additional danmaku from bilibili
     25Parameter 'bilibili', bilibili视频AV号 或者 完整的bilibili视频链接. Additional danmaku from bilibili
    2626Parameter 'danmu', should DPlayer load danmaku. Default false and it's optional.
    2727
     
    3939
    4040== Changelog ==
     41
     42= 1.1.4 =
     43* Extended support for bilibili param, now you can use either
     44- bilibili='23333'
     45- bilibili='http://www.bilibili.com/video/av2333333/index_233.html#page=2333'
     46to load additional danmaku.
     47
     48This plugin will give you exactly the danma that you need, which means,
     49
     50If you give the original URL to the bilibili video, this plugin will identify the URL format, load the right danmaku. In this example, 'http://www.bilibili.com/video/av2333333/index_23333#page=233' is given. And the plugin knows that aid is 2333333 and your requested page is 2333. (According to bilibili, 'index_233.html#page=2333' means that you starts at page 233 but currently you're watching page 2333)
    4151
    4252= 1.1.3 =
  • dplayer-for-wp/trunk/dplayer.php

    r1531408 r1534780  
    33* Plugin Name: DPlayer for WordPress
    44* Description: Wow, such a lovely HTML5 danmaku video player comes to WordPress
    5 * Version: 1.1.3
     5* Version: 1.1.4
    66* Author: 0xBBC
    77* Author URI: https://blog.0xbbc.com/
     
    4848    }
    4949   
     50    public static function dplayer_bilibili_url_handler($bilibili_url) {
     51        $aid = 0;
     52        $page = 1;
     53        $is_bilibili = false;
     54        if (preg_match('/^[\d]+$/', $bilibili_url)) {
     55            $aid = $bilibili_url;
     56            $is_bilibili = true;
     57        } else {
     58            $parsed = parse_url($bilibili_url);
     59            if ($parsed['host'] === 'www.bilibili.com') {
     60                preg_match('/^\/video\/av([\d]+)(?:\/index_([\d]+)\.html)?/', $parsed['path'], $path_match);
     61                if ($path_match) {
     62                    $is_bilibili = true;
     63                    $aid = $path_match[1];
     64                    $page = $path_match[2] == null ? 1 : $path_match[2];
     65                    preg_match('/^page=([\d]+)$/', $parsed['fragment'], $page_match);
     66                    if ($page_match) $page = $page_match[1];
     67                }
     68            }
     69        }
     70
     71        if ($is_bilibili) {
     72            if ($page == 1) {
     73                return array(get_option( 'kblog_danmaku_url', '' ).'bilibili?aid='.$aid);
     74            } else {
     75                $cid = -1;
     76                $json_response = @json_decode(gzdecode(file_get_contents('http://www.bilibili.com/widget/getPageList?aid='.$aid)), true);
     77                if ($json_response) {
     78                    foreach ($json_response as $page_info) {
     79                        if ($page_info['page'] == $page) {
     80                            $cid = $page_info['cid'];
     81                            break;
     82                        }
     83                    }
     84                }
     85               
     86                if ($cid != -1) {
     87                    return array(get_option( 'kblog_danmaku_url', '' ).'bilibili?cid='.$cid);
     88                }
     89            }
     90        }
     91        return null;
     92    }
     93   
    5094    public static function dplayer_load($atts = [], $content = null, $tag = '') {
    5195        // normalize attribute keys, lowercase
     
    88132            'api' => get_option( 'kblog_danmaku_url', '' ),
    89133        );
    90         if ($atts['bilibili']) $danmaku['addition'] = array(get_option( 'kblog_danmaku_url', '' ).'bilibili?aid='.$atts['bilibili']);
     134       
     135        if ($atts['bilibili']) $danmaku['addition'] = DPlayer::dplayer_bilibili_url_handler($atts['bilibili']);
    91136        $data['danmaku'] = ($atts['danmu'] != 'false') ? $danmaku : null;
    92137
  • dplayer-for-wp/trunk/readme.txt

    r1531408 r1534780  
    44Requires at least: 3.0.1
    55Tested up to: 4.6.1
    6 Stable tag: 1.1.3
     6Stable tag: 1.1.4
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2323Parameter 'preload', preload mode, 'auto', 'metatdata' or 'none'. Optional and default metadata.
    2424Parameter 'hotkey', enable builtin hotkey? including left, right and Space. Optional and default true.
    25 Parameter 'bilibili', bilibili视频AV号. Additional danmaku from bilibili
     25Parameter 'bilibili', bilibili视频AV号 或者 完整的bilibili视频链接. Additional danmaku from bilibili
    2626Parameter 'danmu', should DPlayer load danmaku. Default false and it's optional.
    2727
     
    3939
    4040== Changelog ==
     41
     42= 1.1.4 =
     43* Extended support for bilibili param, now you can use either
     44- bilibili='23333'
     45- bilibili='http://www.bilibili.com/video/av2333333/index_233.html#page=2333'
     46to load additional danmaku.
     47
     48This plugin will give you exactly the danma that you need, which means,
     49
     50If you give the original URL to the bilibili video, this plugin will identify the URL format, load the right danmaku. In this example, 'http://www.bilibili.com/video/av2333333/index_23333#page=233' is given. And the plugin knows that aid is 2333333 and your requested page is 2333. (According to bilibili, 'index_233.html#page=2333' means that you starts at page 233 but currently you're watching page 2333)
    4151
    4252= 1.1.3 =
Note: See TracChangeset for help on using the changeset viewer.