使用具有不同质量的视频ID下载Dailymotion视频 [英] Download dailymotion video using video id with different quality

查看:147
本文介绍了使用具有不同质量的视频ID下载Dailymotion视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP创建一个网站,该网站可以使用Dailymotion视频链接下载Dailymotion视频。我搜索了谷歌,发现了一些脚本。但是脚本不起作用。
我上次尝试了以下代码。

I am trying to make a website using PHP which can download Dailymotion video using the Dailymotion video link. I searched google and found some script. But the scripts are not working. I last tried the following code.

$video="x62w2zn";//a static dailymotion video id
$link="";
$page=file_get_contents('http://www.dailymotion.com/embed/video/'.$video);
$link = substr($page, strlen('mp4","url":"')+strripos($page, 'mp4","url":"'));  // beginning of link
$link = substr($link, 0, strpos($link, '"}'));  // end of link
$link = str_replace("\\", '', $link);   // delete backslashes
if(!empty($link)){
    file_put_contents($path_log_link.$video, $link);    // save link in log
    $cmd='wget -bqc '.$link.' -O "'.$path_download_file.$video.'.mp4"';
    exec($cmd,$o,$r);
}

但是此脚本也不起作用。执行后显示空白页面,没有下载任何内容。
请帮助我解决这个问题。

But this script also not working.Showing a blank page after execute and nothing is downloading. Please help me about this problem to solve.

推荐答案

我使用您的代码,它对我有用。 / p>

I use your code and it work for me.

<?php
$videoid="x62w2zn";//a static dailymotion video id
$path_log_link='logs/';
$path_download_file='videos/';
$link="";
$page=file_get_contents('http://www.dailymotion.com/embed/video/'.$videoid);
$link = substr($page, strlen('mp4","url":"')+strripos($page, 'mp4","url":"'));  // beginning of link
$link = substr($link, 0, strpos($link, '"}'));  // end of link
$link = str_replace("\\", '', $link);   // delete backslashes\
$path = $path_download_file.$videoid.".mp4";

if ((!file_exists($path)) && (!empty($link))){
  file_put_contents($path_log_link.$videoid.'.txt', $link); // save link in log
  $cmd='wget -bqc '.$link.' -O "'.$path_download_file.$videoid.'.mp4"';
  exec($cmd,$o,$r);
}
?>

在视频文件夹中获取结果

Get result in videos folder

这篇关于使用具有不同质量的视频ID下载Dailymotion视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆