From 54c5e9f5ead3be7cd345dc9e5f039312e5653405 Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Sun, 31 May 2015 00:16:42 +0200 Subject: [PATCH] [Youtube] Use metatag for publishdate (fix issue #132) --- bridges/YoutubeBridge.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 98abb26f..3861974e 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -24,11 +24,10 @@ class YoutubeBridge extends BridgeAbstract{ public function collectData(array $param){ function getPublishDate($id) { - // relies on Youtube API; deprecated - $json = json_decode(file_get_contents("https://gdata.youtube.com/feeds/api/videos/$id?v=2&alt=json"), TRUE); - $timestamp = strtotime($json['entry']['published']['$t']); + $html2 = file_get_html("https://www.youtube.com/watch?v=$id"); + $timestamp = strtotime($html2->find('meta[itemprop=datePublished]', 0)->getAttribute('content') ); return $timestamp; - } + } $html = '';