Author Topic: YouTube fix for Aeva Media (May 2015)  (Read 274458 times)

0 Members and 1 Guest are viewing this topic.

Offline Nao/Gilles

  • Admin
  • *
  • Posts: 10732
  • Gender: Male
  • Dinosaure de l'animation japonaise, du Net, et de la connerie.
    • View Profile
    • Cynacittà @ noisen
YouTube fix for Aeva Media (May 2015)
So, YouTube isn't going to cooperate with your embeds anymore..?
There's a 'quick' solution, just disable 'lookups' in the Aeva settings. This should help, although you'll still have to manually modify protocols to 'http://' instead of 'https://' when posting a video.

If you want a full-fledged fix, you'll have to do with my diff patches. I'll post updated versions of the AeMe 2.10 files, too, but please remember not to share these outside of this board. Feel free to share the diff patches, though.
If you didn't change the original AeMe files, then feel free to just dropped the fixed files into your Sources folder.
Or, of course, switch to Wedge. ;)

Important note: I only spent an hour or so on this fix. It's quite ugly, as it was backported from the Wedge codebase, and I didn't bother to make many tests for the Aeva-Embed.php changes.

Code: [Select]
--- Sources\Subs-Aeva-Sites.php 2010-10-08 11:56:08.000000000 +-0200
+++ Sources\Subs-Aeva-Sites.php 2015-05-13 16:07:02.000000000 +-0200
@@ -139,27 +139,27 @@
  array(
  'id' => 'ytb',
  'title' => 'YouTube',
  'website' => 'http://www.youtube.com',
  'type' => 'pop',
  'added' => '<4.0',
- 'pattern' => 'http://(?:video\.google\.(?:com|com?\.[a-z]{2}|[a-z]{2})/[^"]*?)?(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"#[]*?(?:&|&amp;|/|\?|;|\%3F|\%2F)(?:video_id=|v(?:/|=|\%3D|\%2F))([\w-]{11})',
- 'movie' => 'http://www.youtube.com/v/$2&rel=0&fs=1',
+ 'pattern' => 'https?://(?:video\.google\.(?:com|com?\.[a-z]{2}|[a-z]{2})/[^"]*?)?(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"#[]*?(?:&|&amp;|/|\?|;|\%3F|\%2F)(?:video_id=|v(?:/|=|\%3D|\%2F))([\w-]{11})',
+ 'movie' => '[url]https://www.youtube.com/v/[/url]$2&rel=0&fs=1',
  'size' => array(
  'normal' => array(480, 385),
  'ws' => array(640, 385),
  ),
  'ui-height' => 25,
  // http://www.youtube.com/watch?v=-X8mD76W4F0 or v=MxGofCFHYCc (all hail Jochen Hippel!)
  // On Google - http://video.google.co.uk/url?docid=-8978185459530152475&ev=v&len=91&srcurl=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dg2cT5J0gxeU
  // http://www.youtube.com/watch?v=M29NUeffJNA - Example of "Embedding Disabled By Request"
- 'fix-html-pattern' => '<object [^>]*><param name="movie" value="http://www\.youtube\.com/v/([\w-]{11})(?:&[^"]*)?">.*?</object>',
- 'fix-html-url' => 'http://www.youtube.com/watch?v=$1',
- 'lookup-url' => 'http://(?:video\.google\.(?:com|com?\.[a-z]{2}|[a-z]{2})/[^"]*?)?(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"#[]*?(?:&|&amp;|/|\?|;|\%3F|\%2F)(?:video_id=|v(?:/|=|\%3D|\%2F))([\w-]{11})[^]#[]*',
- 'lookup-actual-url' => 'http://gdata.youtube.com/feeds/api/videos/$1?v=2',
- 'lookup-final-url' => 'http://www.youtube.com/watch?v=$1',
+ 'fix-html-pattern' => '<object [^>]*><param name="movie" value="https?://www\.youtube\.com/v/([\w-]{11})(?:&[^"]*)?">.*?</object>',
+ 'fix-html-url' => '[url]https://www.youtube.com/watch?v=[/url]$1',
+ 'lookup-url' => 'https?://(?:video\.google\.(?:com|com?\.[a-z]{2}|[a-z]{2})/[^"]*?)?(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"#[]*?(?:&|&amp;|/|\?|;|\%3F|\%2F)(?:video_id=|v(?:/|=|\%3D|\%2F))([\w-]{11})[^]#[]*',
+ 'lookup-actual-url' => '[url]https://www.googleapis.com/youtube/v3/videos?id=[/url]$1',
+ 'lookup-final-url' => '[url]https://www.youtube.com/watch?v=[/url]$1',
  'lookup-title' => true,
  'lookup-title-skip' => true,
  'lookup-pattern' => array(
  'id' => '<id>.*?:([\w-]+)</id>',
  'error' => '<internalReason>(.*?)</internalReason>',
  'noexternalembed' => '<yt:accessControl\saction=\'embed\'\spermission=\'denied\'/>',
@@ -160,19 +160,19 @@
  'lookup-title' => true,
  'lookup-title-skip' => true,
  'lookup-pattern' => array(
  'id' => '<id>.*?:([\w-]+)</id>',
  'error' => '<internalReason>(.*?)</internalReason>',
  'noexternalembed' => '<yt:accessControl\saction=\'embed\'\spermission=\'denied\'/>',
  'id' => 'ytp',
  'title' => 'YouTube (Playlists)',
  'website' => 'http://www.youtube.com',
  'type' => 'pop',
  'added' => '<4.0',
  // http://uk.youtube.com/view_play_list?p=7262E1895FA61B39
- 'pattern' => 'http://(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"]*?(?:&|&amp;|/|\?|;)(?:id=|p=|p/)([0-9a-f]{16})',
+ 'pattern' => 'https?://(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"]*?(?:&|&amp;|/|\?|;)(?:id=|p=|p/)([0-9a-f]{16})',
  'movie' => 'http://www.youtube.com/p/$2&rel=0&fs=1',
  'size' => array(480, 385),
  'ui-height' => 25,
  'fix-html-pattern' => '<object [^>]*><param name="movie" value="$1" />.*?</object>',
  ),
  array(

Then...

Code: [Select]
--- Sources\Aeva-Embed.php 2010-11-19 11:29:34.000000000 +-0200
+++ Sources\Aeva-Embed.php 2015-05-13 16:00:29.000000000 +-0200
@@ -106,13 +106,13 @@
  // For each enabled site to the end, attempt to embed
  for ($upto = 0; $upto < $j; $upto++)
  {
  $message = aeva_match($message);
 
  // If no active http links remain (making further embedding impossible), then stop
- if (stripos($message, '<a href="http://') === false)
+ if (stripos($message, '<a href="http') === false)
  break;
  }
 
  // Reverse protections and return the finished embedded content
  return aeva_reverse_protection(str_replace('<aeva-begin>', '', $message));
 }
@@ -113,28 +113,28 @@
  break;
  }
 
  // Reverse protections and return the finished embedded content
  return aeva_reverse_protection(str_replace('<aeva-begin>', '', $message));
 }
  }
 
  // Tidy up
  unset($unaltered);
 
  // No links remaining?  No further embedding possible, so set this variable before we return
- if ($reverse === true && stripos($input, '<a href="http://') === false)
+ if ($reverse === true && stripos($input, '<a href="http') === false)
  $context['aeva']['skip'] = true;
 
  return $input;
 }
 
 // Protect noembed & autolink items from embedding *before* BBC parsing - wrap quotes, but don't protect
 function aeva_preprotect(&$message, $cache_id)
 {
- if ((stripos($message, 'http://') === false && stripos($message, '') === false) || strpos($cache_id, 'sig') !== false)
+ if ((stripos($message, '://') === false && stripos($message, '') === false) || strpos($cache_id, 'sig') !== false)
  return;
 
  global $modSettings, $context;
 
  if (!empty($modSettings['cache_enable']))
  {
@@ -202,19 +202,19 @@
  return;
 
  global $modSettings, $context;
 
  if (!empty($modSettings['cache_enable']))
  {
 
  // Should haven't got here if autolinking of urls is disabled
  if (empty($modSettings['autoLinkUrls']))
  return $input;
 
  // Parse any URLs....
- if (preg_match('~http://|www\.~i', $input))
+ if (preg_match('~https?://|www\.~i', $input))
  {
  // Modified from SMF code, adding support for [center], [li], [td] and closing tags.
  $input = strtr($input, array('&#039;' => '\'', '&quot;' => '>">', '"' => '<"<', '&lt;' => '&lt;'));
  $input = preg_replace(
  array(
  '`(^|[\s>\.(;\'"]|\[(?:center|li|td|youtube|/\w+)])((?:http|https|ftp|ftps)://[\w%@:|-]+(?:\.[\w%-]+)*(?::\d+)?(?:/[\w\~%\.@,\?&;=#+:\'\\\\-]*|[\(\{][\w\~%\.@,\?&;=#(){}+:\'\\\\-]*)*[/\w\~%@\?;=#}\\\\-]?)`i',
@@ -705,19 +705,19 @@
  {
  // Modified from SMF code, adding support for [center], [li], [td] and closing tags.
  $input = strtr($input, array('&#039;' => '\'', '&quot;' => '>">', '"' => '<"<', '&lt;' => '&lt;'));
  $input = preg_replace(
  array(
  '`(^|[\s>\.(;\'"]|\[(?:center|li|td|youtube|/\w+)])((?:http|https|ftp|ftps)://[\w%@:|-]+(?:\.[\w%-]+)*(?::\d+)?(?:/[\w\~%\.@,\?&;=#+:\'\\\\-]*|[\(\{][\w\~%\.@,\?&;=#(){}+:\'\\\\-]*)*[/\w\~%@\?;=#}\\\\-]?)`i',
  global $context, $modSettings, $txt, $aeva_timer;
 
  $aeva_timer = (isset($aeva_timer) ? (int) $aeva_timer : 0) - array_sum(explode(' ', microtime()));
 
  if (strlen($message) > 10 & empty($context['uninstalling']))
  {
- if (!empty($modSettings['aeva_enable']) && empty($context['aeva_disable']) && stripos($message, 'http://') !== false && $smileys !== 'print' && strpos($cache_id, 'sig') === false)
+ if (!empty($modSettings['aeva_enable']) && empty($context['aeva_disable']) && stripos($message, '://') !== false && $smileys !== 'print' && strpos($cache_id, 'sig') === false)
  $message = aeva_main($message);
  else
  {
  // Removes any noembed
  $message = aeva_protection(
  array('noembed' => false),
@@ -1070,27 +1070,27 @@
  $message = aeva_main($message);
  else
  {
  // Removes any noembed
  $message = aeva_protection(
  array('noembed' => false),
  global $embed_album, $embed_folder, $context, $force_id;
 
  $link = preg_replace(array('~\[url=([^]]*)]([^[]*)\[/url]~', '~\[url]([^[]*)\[/url]~'), array('$1', '$1'), $link);
  $thumbs = array(
  'YouTube' => array(
  'func' => 'youtubeCreateThumb',
- 'pattern' => 'http://(?:video\.google\.(?:com|com?\.[a-z]{2}|[a-z]{2})/[^"]*?)?(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"#[]*?(?:&|&amp;|/|\?|;|\%3F|\%2F)(?:video_id=|v(?:/|=|\%3D|\%2F))([\w-]{11})',
+ 'pattern' => 'https?://(?:video\.google\.(?:com|com?\.[a-z]{2}|[a-z]{2})/[^"]*?)?(?:(?:www|[a-z]{2})\.)?youtube\.com/[^"#[]*?(?:&|&amp;|/|\?|;|\%3F|\%2F)(?:video_id=|v(?:/|=|\%3D|\%2F))([\w-]{11})',
  ),
  'Dailymotion' => array(
  'func' => 'dailymotionCreateThumb',
  'pattern' => 'http://(?:www\.)?dailymotion\.(?:com|alice\.it)/(?:[^"]*?video|swf)/([a-z0-9]{1,18})',
  ),
  'GoogleVideo' => array(
  'func' => 'googleCreateThumb',
- 'pattern' => 'http://video\.google\.(com|com?\.[a-z]{2}|[a-z]{2})/(?:videoplay|url|googleplayer\.swf)\?[^"]*?docid=([\w-]{1,20})',
+ 'pattern' => 'https?://video\.google\.(com|com?\.[a-z]{2}|[a-z]{2})/(?:videoplay|url|googleplayer\.swf)\?[^"]*?docid=([\w-]{1,20})',
  ),
  'GoogleMaps' => array(
  'func' => 'gmapsCreateThumb',
  'pattern' => 'http://maps\.google\.[^">]+/\w*?\?[^">]+',
  ),
  'MetaCafe' => array(
« Everyone knows rock attained perfection in 1974. It's a scientific fact. »

Offline smap

  • Newbie
  • *
  • Posts: 3
  • Gender: Male
    • View Profile
I don't know if this helps or not, but what I found out is this

Open any youtube video directly on your browser, let's use the one bellow

https://www.youtube.com/watch?v=wjj7fBkcQCE

Just bellow the video you will find 3 buttons

+ add to | < share | ... More

press the share button, and the link to be usen is rewritten

https://youtu.be/wjj7fBkcQCE

so instead of

www.youtube.com

you get

youtu.be

and instead of

watch?v=wjj7fBkcQCE

you get

wjj7fBkcQCE

Obviously you still need to take out the "s" on the protocol name (http:// instead of https://), but it will work


One question, I'm using smf 2.0.10 with Aeva Media (1.4w) and not wedge, can I use/adapt your code to try to fix the problem or you don't allow it?


Offline Nao/Gilles

  • Admin
  • *
  • Posts: 10732
  • Gender: Male
  • Dinosaure de l'animation japonaise, du Net, et de la connerie.
    • View Profile
    • Cynacittà @ noisen
The code I posted above was for AeMe 2.10, not Wedge. I believe it also works without changes for v1.4... Make sure to apply the diff manually for best results! And feel free to share your updated files if they're not identical.
« Everyone knows rock attained perfection in 1974. It's a scientific fact. »

Offline saks2008

  • Cynois
  • ***
  • Posts: 102
  • Gender: Male
  • No work? no money? no future? Time to fly!
    • View Profile
    • Paragliding and kiting in Krasnoyarsk
Hi Nao! I am download corrected files and replace old with it, but links with "https" is not show how youtube video.
I am using Aeva Media 2.10
No work? No money? No future? Time to fly!

Argon2020

  • Guest
  •  
SMF 2.0.15 + Aeva Media 2.10 on PHP 7.0 = not work Youtube
Hello!

SMF 2.0.15 + Aeva Media 2.10 on PHP 5.6 = work Youtube.

SMF 2.0.15 + Aeva Media 2.10 on PHP 7.0 = not work Youtube.
On-screen text Youtube: "An error occurred. Please try again later (playback ID=...)"

Please, help?

Offline Nao/Gilles

  • Admin
  • *
  • Posts: 10732
  • Gender: Male
  • Dinosaure de l'animation japonaise, du Net, et de la connerie.
    • View Profile
    • Cynacittà @ noisen
I have no idea... You should provide a link to a page in action.
« Everyone knows rock attained perfection in 1974. It's a scientific fact. »