Sign up here and you can log into the forum!

UMSP Plugin: youporn

UMSP Plugin Depot, the place for sharing plugins & info about them. No requests, just plugins/code.

UMSP Plugin: youporn   

Postby TroNik » Fri Dec 30, 2011 2:45 am

Image
youporn


The plugin supports:
1) New Videos (Sort by: Hybrid, Views, Rating, Duration, Submission time, Video title)
2) Top Rated (Today, Yesterday, This Week, This Month, This Year, All Time)
3) Most Viewed (Today, Yesterday, This Week, This Month, This Year, All Time)
4) Categories (53 different categories and Sort by: Date, Views, Rating, Duration)
5) Search
6) Configuration to enable/disable HQ

Download from SVN or: http://www.mediafire.com/?2dacndai5cq5kuu

Code: Select all
<?php

function _pluginMain($prmQuery) {
  if (strpos($prmQuery, '&amp;') !== false) $prmQuery = str_replace('&amp;', '&', $prmQuery);
  parse_str($prmQuery, $params);
  if (isset($params['f']) && function_exists($params['f'])) {
    if (isset($params['args'])) {
      return call_user_func_array($params['f'], $params['args']);
    } else {
      return call_user_func($params['f']);
    }
  }
  return main_menu();
}

function _pluginSearch($prmQuery) {
  if (preg_match('/and dc:(?:title|album|genre) contains "(.*?)"/', $prmQuery, $query)) {
    $query = $query[1];
    return search($query);
  }
}

function build_query($f, $args = array()) {
  return http_build_query(array('f' => $f, 'args' => $args), '', '&amp;');
}

function build_umsp_url($f, $args = array()) {
  return 'umsp://plugins/youporn/youporn?' . build_query($f, $args);
}

function main_menu() {
  $Items[] = array (
    'id' => build_umsp_url('browse'),
    'dc:title' => 'New Videos',
    'upnp:album_art'=> 'http://lh6.googleusercontent.com/-FSUuQc9U7g0/TvGyaHqwl_I/AAAAAAAAAD8/2bRNHGaKh1I/s220/popcorn.png',
    'upnp:class' => 'object.container',
  );
  $Items[] = array (
    'id' => build_umsp_url('orderby', array('top_rated')),
    'dc:title' => 'Top Rated',
    'upnp:album_art'=> 'http://lh6.googleusercontent.com/-xYe4abRaD0M/TvGya-uROdI/AAAAAAAAAEE/ycci4mroXzc/s220/oscar.png',
    'upnp:class' => 'object.container',
  );
  $Items[] = array (
    'id' => build_umsp_url('orderby', array('most_viewed')),
    'dc:title' => 'Most Viewed',
    'upnp:album_art'=> 'http://lh5.googleusercontent.com/-Sm0NVoqNK4E/TvGyeR-aprI/AAAAAAAAAEc/bhg9IkceDX0/s220/clapperboard.png',
    'upnp:class' => 'object.container',
  );
  $Items[] = array (
    'id' => build_umsp_url('categories'),
    'dc:title' => 'Categories',
    'upnp:album_art'=> 'http://lh6.googleusercontent.com/-PfHfJ1T3nnc/Tvf6HXfZh2I/AAAAAAAAAFM/AMxQv6-LzJ0/s220/Directors%252520chair.png',
    'upnp:class' => 'object.container',
  );
  $Items[] = array (
    'id' => build_umsp_url('search_button'),
    'dc:title' => 'Search youporn: press search on remote or use this option',
    'upnp:album_art'=> 'http://lh3.googleusercontent.com/-F9qS4ys3A6M/TvGzha58eYI/AAAAAAAAAEw/2b1JcrEneXA/s220/search_icon.png',
    'upnp:class' => 'object.container',
  );
  $Items[] = array (
    'id' => build_umsp_url('config'),
    'dc:title' => 'Configure Plugin',
    'upnp:album_art'=> 'http://lh5.googleusercontent.com/-xsH3IJAYXd0/TvwfRdc7DMI/AAAAAAAAAFk/NmvkjuqP_eo/s220/Settings.png',
    'upnp:class' => 'object.container',
  );
  return $Items;
}

function browse($sort = '') {
  if ($sort == '') {
    foreach (array('hybrid', 'views', 'rating', 'duration', 'time', 'title') as $sort) {
      $Items[] = array(
        'id' => build_umsp_url('browse', array($sort)),
        'dc:title' => 'Sort by: ' . $sort,
        'upnp:class' => 'object.container',
      );
    }
    return $Items;
  }
  return videos("http://www.youporn.com/browse/$sort");
}

function orderby($orderby, $duration = '') {
  if ($duration == '') {
    foreach (array('today', 'yesterday', 'week', 'month', 'year', 'all') as $duration) {
      $Items[] = array(
        'id' => build_umsp_url('orderby', array($orderby, $duration)),
        'dc:title' => $duration,
        'upnp:class' => 'object.container',
      );
    }
    return $Items;
  }
  return videos("http://www.youporn.com/$orderby/$duration");
}

function categories($category = '', $sortby = '') {
  if ($category == '') {
    $data = file_get_contents('http://www.youporn.com/categories');
    if (preg_match_all('@<li><a href="(?P<category>/category/\d+/[a-z]*)/">' .
        '(?P<category_title>[^<]+)</a></li>@', $data, $matches, PREG_SET_ORDER)) {
      echo count($matches);
      foreach ($matches as $match) {
        $Items[] = array(
          'id' => build_umsp_url('categories', array($match['category'])),
          'dc:title' => $match['category_title'],
          'upnp:class' => 'object.container',
        );
      }
    }
    return $Items;
  } else if ($sortby == '') {
    foreach (array('date', 'views', 'rating', 'duration') as $sortby) {
      $Items[] = array(
        'id' => build_umsp_url('categories', array($category, $sortby)),
        'dc:title' => 'Sort by: ' . $sortby,
        'upnp:class' => 'object.container',
      );
    }
    return $Items;
  }
  return videos("http://www.youporn.com/$category/$sortby");
}

function videos($url, $page = 1) {
  $prefer_hq = getConfigValue('PREFER_HQ', '1');
  $data = file_get_contents("$url?page=$page");
  if (preg_match_all('@<a href="/watch/(?P<video_id>\d+)[^"]*">\s*' .
      '<img id="thumb\d*" src="(?P<thumb>[^"]*)" num="\d*" width="160" height="120" alt="(?P<title>[^"]*)"' .
      '@', $data, $matches, PREG_SET_ORDER)) {
    foreach ($matches as $match) {
      $video_id = $match['video_id'];
      $Items[] = array(
        'id' => build_umsp_url('play', array($video_id)),
        'res' => 'http://127.0.0.1/umsp/plugins/youporn/youporn.php?video=' . urlencode($video_id) . '&hq=' . $prefer_hq,
        'dc:title' => $match['title'],
        'upnp:album_art' => $match['thumb'],
        'upnp:class' => 'object.item.videoitem',
        'protocolInfo' => 'http-get:*:video/*:*',
      );
    }
  }
  $Items[] = array(
    'id' => build_umsp_url('videos', array($url, $page + 1)),
    'dc:title' => 'Next Page',
    'upnp:album_art' => 'http://lh5.googleusercontent.com/-NbZDnulY1HA/TvGycw-YIlI/AAAAAAAAAEM/mu3w8ZWlRkc/s200/next.png',
    'upnp:class' => 'object.container',
  );
  return $Items;
}

function get_video_url($download_id) {
  $data = simplexml_load_file("http://download.youporn.com/download/$download_id?xml=1");
  return (string) $data->trackList->track->location;
}

function search_button() {
  exec("sudo chmod 666 /tmp/ir_injection && sudo echo E > /tmp/ir_injection &");
  return main_menu();
}

function search($query) {
  $url = 'http://www.youporn.com/search?query=' . urlencode($query);
  return videos($url);
}

function config($key = null, $value = null) {
  if ($key != null) {
    putConfigValue($key, $value);
  }
  $prefer_hq = getConfigValue('PREFER_HQ', 1);
  $Items[] = array(
    'id' => build_umsp_url('config', array('PREFER_HQ', !$prefer_hq)),
    'dc:title' => 'HQ is ' . ($prefer_hq ? 'on' : 'off') . ' - Select to ' . ($prefer_hq ? 'disable' : 'enable'),
    'upnp:album_art'=> 'http://lh5.googleusercontent.com/-zRoJYr2StdU/Twv91J6lV-I/AAAAAAAAAak/k6rAwTfP4xo/s128/HQ.png',
    'upnp:class' => 'object.container',
  );
  $Items[] = array(
    'id' => build_umsp_url('main_menu'),
    'dc:title' => 'Back',
    'upnp:album_art'=> 'http://lh3.googleusercontent.com/-dsT4ZvjCth4/TvwihbvNZLI/AAAAAAAAAF0/1Jp9s8dLNlY/s220/back_button_icon.png',
    'upnp:class' => 'object.container',
  );
  return $Items;
}

function getConfigValue($key, $default_value) {
  $conf_dir = function_exists('_getUMSPConfPath') ? _getUMSPConfPath() : '/conf';
  $config = file_get_contents($conf_dir . '/config');
  if (preg_match("/YOUPORN_$key='(.+)'/", $config, $matches)) {
    return trim($matches[1]);
  }
  return $default_value;
}

function putConfigValue($key, $value) {
  exec("sudo config_tool -c YOUPORN_$key='$value' >/dev/null 2>&1");
}

if (isset($_GET['video'])) {
  $video_id = $_GET['video'];
  $hq = isset($_GET['hq']) ? $_GET['hq'] : 1;
  $data = file_get_contents("http://www.youporn.com/watch/$video_id");
  if (preg_match_all('@<p><a href="http://download.youporn.com/download/(?P<download_id>\d+)\?save=1">' .
      'MP4[^<]*</a>\s*(?P<size>[^<]*)</p>' .
      '@', $data, $matches, PREG_SET_ORDER)) {
    if ($hq) {
      $download_id = $matches[0]['download_id'];
    } else {
      $download_id = $matches[count($matches) - 1]['download_id'];
    }
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . get_video_url($download_id));
    exit();
  }
}

?>


Code: Select all
<?php

# meta-name="youporn"
# meta-desc="youporn"
# meta-author="TroNik"
# meta-date="2012-01-10"
# meta-version="0.0.3"
# meta-type="umsp"
# meta-url="http://forum.wdlxtv.com/viewtopic.php?f=53&t=6224"
# meta-filename="youporn.php"
# meta-id="youporn"
# meta-basefirmware="*"
# meta-thumbnail="http://files.youporn.com/r/11/images/youporn.png"
# meta-rating="General"
# meta-category="XXX Adult"

global $pluginInfo;

$pluginInfo = array (
   'name'      => 'youporn',
   'desc'      => 'youporn',
   'author'   => 'TroNik',
   'date'      => '2012-01-10',
   'version'   => '0.0.3',
   'rating'   => 'Adult',
   'url'      => 'http://forum.wdlxtv.com/viewtopic.php?f=53&t=6224',
   'id'      => 'youporn',
   'thumb'      => 'http://files.youporn.com/r/11/images/youporn.png',
   'art'      => 'http://files.youporn.com/r/11/images/youporn.png',
);

?>
Last edited by TroNik on Tue Jan 10, 2012 1:08 am, edited 1 time in total.
TroNik
Developer
 
Posts: 73
Joined: Wed Dec 21, 2011 2:56 am

Re: UMSP Plugin: youporn   

Postby mad_ady » Fri Dec 30, 2011 8:37 am

Added to SVN
User avatar
mad_ady
Developer
 
Posts: 4564
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP Plugin: youporn   

Postby foxer » Sun Jan 08, 2012 4:18 am

I don't know if anyone actually tested it, but I get the "no media in folder" error when I select a video to play. When I test it via umsp-test.php I get the video qualities listed and I can click on them. I've found the problem below:
Code: Select all
function get_video_url($download_id) {
  $data = simplexml_load_file("http://download.youporn.com/download/$download_id?xml=1");
  return (string) $data->trackList->track->location;
}


The return value must be a string - and by default it is a simplexml object. I cast it and now it works. Hope somebody can upload the changes.

Also, an idea for improvement: when viewing such "content", one would prefer not to use a remote. Instead of using a proxy to scrape out the video urls, you did it in the main plugin. While this is a good idea, it limits playback (the user has to navigate back and forth inside the plugin).

Anyway - it's a welcomed addition to the adult plugins - good job. I didn't know youporn had mp4 content :)
foxer
WDTVer
 
Posts: 48
Joined: Wed Nov 24, 2010 9:45 am

Re: UMSP Plugin: youporn   

Postby mad_ady » Sun Jan 08, 2012 4:23 am

Uploaded fix to svn
User avatar
mad_ady
Developer
 
Posts: 4564
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP Plugin: youporn   

Postby TroNik » Tue Jan 10, 2012 1:10 am

1st post updated with a new version that adds a setting to enable/disable HQ.
TroNik
Developer
 
Posts: 73
Joined: Wed Dec 21, 2011 2:56 am

Re: UMSP Plugin: youporn   

Postby mad_ady » Tue Jan 10, 2012 6:24 am

Uploaded fix to SVN. Also, I've changed manual mappings to 127.0.0.1 to $_SERVER[HTTP_HOST] for consistency and future compatibility
User avatar
mad_ady
Developer
 
Posts: 4564
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: UMSP Plugin: youporn   

Postby S4bb3 » Wed Apr 11, 2012 1:32 am

This plugin doesn't seem to work atm.
S4bb3
Donor
 
Posts: 41
Joined: Fri Apr 30, 2010 10:01 pm

Re: UMSP Plugin: youporn   

Postby shinshunshuu » Thu Apr 12, 2012 9:01 pm

Plugin working fine for me.
shinshunshuu
n00b
 
Posts: 1
Joined: Sun Feb 12, 2012 12:52 pm

Re: UMSP Plugin: youporn   

Postby jmaraujo » Tue Mar 29, 2016 8:34 am

Can anyone please fix the YouPorn plugin?* I tried to do it myself but couldn't fix it. :oops:


My PHP knowledge is very basic to fix it myself... :roll: So, all I could do was to fix the category navigation... :lol:
Code: Select all
$category_href_regexp '<a href="(?P<category>/category/\d+/[a-z-]*)/"[^>]*>';
    if (
preg_match_all('@<li>' $category_href_regexp 

by adding '.*?' inside the <li> tag. (they added CSS classes to all list elements)
Code: Select all
$category_href_regexp '<a href="(?P<category>/category/\d+/[0-9a-z-]*)/"[^>]*>';
    if (
preg_match_all('@<li .*?>' $category_href_regexp .  
...and also added '0-9' to [a-z-], so the 3D category is also included.


Can anyone please fix this plugin? ;)







(*) PS: Redtube is still working if you edit the ampersand...
Code: Select all
"id"         => "umsp://plugins/redtube?cat=$cat&pag=$pag"
...to...
Code: Select all
"id"         => "umsp://plugins/redtube?cat=$cat&amp;pag=$pag"
...but Redtube plugin is extremely slow, and has no search.
User avatar
jmaraujo
WDTVer
 
Posts: 30
Joined: Sun Feb 19, 2012 3:01 pm

Re: UMSP Plugin: youporn   

Postby mad_ady » Tue Mar 29, 2016 10:09 pm

Are these all the changes you need to make? I can commit them if you make it work, but I don't have the time to fix it, sorry :roll:
User avatar
mad_ady
Developer
 
Posts: 4564
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Next

Return to UMSP Plugins

Who is online

Users browsing this forum: No registered users and 1 guest