Pornhub provider at wp video thumbnails

Status
Not open for further replies.

diancordo

Member
12
2016
1
0
Hi! I was trying to add pornhub provider to this wordpress plugin:
wordpress.org/plugins/video-thumbnails/


I don't know much about php, but tried as follow:
at /php/providers/
copied and modified class-youtube-thumbnails.php
to class-pornhub-thumbnails.php
Inside turn to
Code:
<?php


/*  Copyright 2014 Sutherland Boswell  (email : sutherland.boswell@gmail.com)




    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as 
    published by the Free Software Foundation.




    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.




    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/




// Require thumbnail provider class
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-provider.php' );




class Pornhub_Thumbnails extends Video_Pornhub_Provider {




    // Human-readable name of the video provider
    public $service_name = 'Pornhub';
    const service_name = 'Pornhub';
    // Slug for the video provider
    public $service_slug = 'pornhub';
    const service_slug = 'pornhub';




    public static function register_provider( $providers ) {
        $providers[self::service_slug] = new self;
        return $providers;
    }




    // Regex strings
    public $regexes = array(
        '#http:\/\/i[0-9]\.cdn2b\.image\.pornhub\.phncdn\.com\/m=eqgl9daaaa\/videos\/[0-9]+\/18\/([0-9]+)\/original\/0\.jpg#'
    );




    // Thumbnail URL
    public function get_thumbnail_url( $id ) {
        $maxres = 'http://i1.cdn2b.image.pornhub.phncdn.com/m=eqgl9daaaa/videos/201603/18/' . $id . '/maxresdefault.jpg';
        $response = wp_remote_head( $maxres );
        if ( !is_wp_error( $response ) && $response['response']['code'] == '200' ) {
            $result = $maxres;
        } else {
            $result = 'http://i1.cdn2b.image.pornhub.phncdn.com/m=eqgl9daaaa/videos/201603/18/' . $id . '/0.jpg';
        }
        return $result;
    }




    // Test cases
    public static function get_test_cases() {
        return array(
            array(
                'markup'        => '<iframe width="560" height="340" src="http://www.pornhub.com/embed/795042586" frameborder="0" allowfullscreen></iframe>',
                'expected'      => 'http://i1.cdn2b.image.pornhub.phncdn.com/m=eqgl9daaaa/videos/201603/18/71401281/original/0.jpg',
                'name'          => __( 'iFrame Embed SD', 'video-thumbnails' )
            ),
            array(
                'markup'        => '<object width="560" height="340"><param name="movie" value="http://www.pornhub.com/embed/795042586"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.pornhub.com/view_video.php?viewkey=795042586" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>',
                'expected'      => 'http://i1.cdn2b.image.pornhub.phncdn.com/m=eqgl9daaaa/videos/201603/18/71401281/original/0.jpg',
                'name'          => __( 'Flash Embed SD', 'video-thumbnails' )
            ),
        );
    }




}




?>
And also added two lines here:
php/providers.php


But it was not so easy for a newbie...
Hope you can help me with that.
The outcome? Just got thumbnails from pornhub videos.
Thanks in advance!

PS: This questions is related to this topic http://www.wjunction.com/200-development-area-archive/163258-regex-pornhub.html
created by @skinner and helped by @lock down and @jokerhacker

__________________
Added after 1:

Unconsciously erased part of the question. Hope now it's all ok.

__________________
Added after 13 Days:

No one?

Anyone?
Hope to find a solution soon.
 
Last edited:
Status
Not open for further replies.
Back
Top