I need convert youtube video to mp3 using Quick MP3 API.
http://www.quick-mp3.com/api/v1/docs/
my code example is :
<?php
$url="http://www.youtube.com/watch?v=qpgTC9MDx1o";
// i need to fetch video informations and get mp3 download link
?>
Thank you.
try this code :
don't forgot to include quick_func.php in your php code
require_once('./quick_func.php'); // quick mp3 functions
$url = "http://www.youtube.com/watch?v=qpgTC9MDx1o";
$exp = explode("?v=",$url);
$vid = $exp[1];
$data = Convert_Vid($vid); // video id to convert
$id = $data['id']; // get video id
$title = $data['ttl']; // get video title
$duration = $data['duration']; // get video duration
$thumb = $data['thumb']; // get video thumb
$mp3 = $data['mp3']; // get mp3 download link
print_r($data);
you need to transform your full youtube url to video ID :
$url = "http://www.youtube.com/watch?v=qpgTC9MDx1o"; // full youtube url
$exp = explode("?v=",$url); // explode url
$vid = $exp[1]; // get id after ?v=
Enjoy ;)
You should try below API to get mp3 format of any YouTube video as quick-mp3 is no more available.
<iframe id="buttonApi" src="https://convert2mp3s.com/api/button/mp3?url=https://www.youtube.com/watch?v=pRpeEdMmmQ0" width="100%" height="100%" allowtransparency="true" scrolling="no" style="border:none"></iframe>
GitHub Project: https://github.com/matthew-asuncion/Fast-YouTube-to-MP3-Converter-API
Related
Below code, I got title and description but I want image as well as
how to get the main image of video from JSON data.
$videoid = 'cMC_PtgKDJE';
$apikey = 'xyzxyzxyz'; //My API key
$json = file_get_contents('https://www.googleapis.com/youtube/v3/videos?id='.$videoid.'&key='.$apikey.'&part=snippet');
$ytdata = json_decode($json);
print_r($ytdata);
echo '<h1>Title: ' . $ytdata->items[0]->snippet->title . '</h1>';
echo 'Description: ' . $ytdata->items[0]->snippet->description;
Each YouTube video has 4 generated images.You can create the url as fallows
https://img.youtube.com/vi/<video-id-here>/0.jpg
DEMO
If you want high quality image then you can read following atricle
how to get a youtube video’s thumbnail image in high quality
How to get video id from youtube url
$url = "http://www.youtube.com/watch?v=7zWKm-LZWm4&feature=relate";
parse_str( parse_url( $url, PHP_URL_QUERY ), $url_vars );
echo $url_vars['v'];
// Output: 7zWKm-LZWm4
?>
Each video on YouTube provides several thumbnails of different quality
Default (for small thumbnails):
$ytdata->items[0]->snippet->thumbnails->default->url;
Medium:
$ytdata->items[0]->snippet->thumbnails->medium->url;
High:
$ytdata->items[0]->snippet->thumbnails->high->url;
Standard:
$ytdata->items[0]->snippet->thumbnails->standard->url;
Maximum resolution:
$ytdata->items[0]->snippet->thumbnails->maxres->url;
I want to get thumbnail of facebook videos from a given video ID .
I use the preg_match function to get facebook video ID from a given url retrieved from database
preg_match("~/videos/(?:t\.\d+/)?(\d+)~i", $value->url, $matches);
$video_id = $matches[1];
echo ' <div class="fb-video" data-href="https://www.facebook.com/facebook/videos/'.$video_id.'/"></div>';
I want to posted on website with something like this:
<img src="VIDEO_IMAGE.<?php echo $video_id ?>.jpg">
I don't know if it' posssible? !
Your image source is wrong try using
<img src="https://graph.facebook.com/VIDEO_ID/picture" />
Example : https://graph.facebook.com/10153231379946729/picture
I have to get trailer and playlist which are on home page of my channel.
I tried to use Activities with home parameter but nothing that I get back permit me to get playlist or trailer.
Here's some of my relevant code:
$oYoutubeService = new Google_Service_YouTube($oGoogle);
$playlists_optParams = array('home' => true);
$stream = $oYoutubeService->activities->listActivities('snippet', $playlists_optParams);
var_dump($stream);
but in this result I haven't any trailer or playlist.
If my goal is not clear, for example on the channel youtube.com/user/youtubenationI would like to get the trailer ("Nicole Richie keeps...") and playlist after ("YouTube Nation Playlist", "True Facts About Ze Frank"...)
Is there a simple way to get back the trailer, playlist or video from channel's home page ?
Thanks
I built this messy code snippet that grabs a youtube channel page and strips out the video trailer ID, and then embeds the video. It was for another project, and could use some tidying up.
<?php
// Fetch YouTube channel page.
// ------REPLACE THE ADDRESS INSIDE THE QUOTES WITH THE DESIRED YOUTUBE CHANNEL------
$html = file_get_contents('http://www.youtube.com/user/YOUR_YOUTUBE_CHANNEL/');
// Identifies what text we are searching for, then returns the cursor position in the file where that text string begins.
$videoID = 'data-video-id';
$pos = stripos($html, $videoID);
// Remove all of the content before the data-video-id, and remove the new first 15 characters of the file, which would now be-> data-video-id:"
$str2 = substr($html, $pos);
$str3 = substr($str2, 15);
// Grab the first 11 characters, cause YouTube video IDs are 11 characters long.
$id = substr($str3, 0,11);
// Create a string with the youtube video URL, using the ID variable.
$ytlink = 'http://www.youtube.com/v/' . $id;
//Determine whether user is mobile, and if they are, don't size the video.
$isMobile = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'Mobile');
if ($isMobile) {
$size = " ";
} else {
//These values can be changed to your own needs.
$size = "width=425 height=350";
}
// Embed the YouTube video.
echo '<object ' . $size . ' data="' . $ytlink . '"type="application/x-shockwave-flash">';
echo '<param name="src" value="' . $ytlink . '" /></object>';
?>
I want to get the large facebook video thumbnail using graph. Below code get the small thumbnail
https://graph.facebook.com/VIDEO_ID/picture
This code will return Ex:
https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-prn1/632393_10151574602254838_10151574598089838_34404_282_t.jpg
If i replace "t" with "n" i will get the large image
https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-prn1/632393_10151574602254838_10151574598089838_34404_282_n.jpg
But how do i get it using facebook graph or replace "t" with "n" using php
Thanks in advance.
you can use this php code, its working for me.
<?php
$video_id = "10153231379946729";
$xml = file_get_contents('http://graph.facebook.com/' . $video_id);
$result = json_decode($xml);
$small = $result->format[0]->picture;
$medium = $result->format[1]->picture;
//fetch the 720px sized picture
$large = $result->format[3]->picture;
?>
<img src="<?php echo $medium;?>">
How to get video.mp4 from vine url?
Example:
from https://vine.co/v/hnVVW2uQ1Z9
I need http://.../*.mp4 and http://.../*.jpg
Script what I need use this page vinebed.com
(In PHP)
Thanks much.
It's very simple. if you check the source of a vine video from vine.co you'll see the meta tags. and you should see twitter:player:stream. By using php you can extract that information specifically and use it like a variable.
<?php
function vine( $id )
{
$vine = file_get_contents("http://vine.co/v/{$id}");
preg_match('/property="twitter:player:stream" content="(.*?)"/', $vine, $matches);
$url = $_SERVER['REQUEST_URI'];
return ($matches[1]) ? $matches[1] : false;
}
?>
And to set an $id you will need to create a function that will either A) Automatically read a vine video id by url and you can display it like this <?php echo vine('bv5ZeQjY35'); ?> or B) Just set a vine video id and display as is.
Hope this helps as it's worked for me just fine.