Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Odczyt tagów filmu z YouTube
northwest
post
Post #1





Grupa: Zarejestrowani
Postów: 788
Pomógł: 1
Dołączył: 17.09.2004

Ostrzeżenie: (10%)
X----


Witam (IMG:style_emoticons/default/smile.gif)
Potrzebuję zrobić odczyt długości kliku bezpośrednio z youtube. Znalazłem takie rozwiązanie:
  1. $xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/G-hW-0MP5lI');
  2. echo"<pre>";
  3. print_r($xml);
  4. echo"</pre>";


Ale podaje niestety wszystko prócz czasu trwania... Wiecie może jak odczytać ten czas?

Northwest
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Sephirus
post
Post #2





Grupa: Zarejestrowani
Postów: 1 527
Pomógł: 438
Dołączył: 28.06.2011
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


  1.  
  2. $site = file_get_contents('adres_strony_YT');
  3. preg_match('/<meta\s*itemprop="duration"\s*content="([^"]+)">/si',$site,$match);
  4.  
  5. $di = new DateInterval($match[1]);
  6.  
  7. echo 'Kawalek trwa: '.$di->h.' godzin '.$di->i.' minut '.$di->s.' sekund';
  8.  
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.10.2025 - 18:03