dongzecai0684 2013-07-13 04:10
浏览 28
已采纳

能够在2分钟内发布YouTube视频

Is there any way for a website to let users embed ONLY short youtube videos. Let's say 2min or shorter.

So when they try to embed the youtube video and if it's over 2 minutes they get an error that tells them "Your video is too long, please choose another" etc...

Is this possible?

Just to be clear, I'm not looking to edit the youtube video length, just prohibit users from posting of videos that are too long.

Thank you very much.

  • 写回答

2条回答 默认 最新

  • doublel83422 2013-07-13 04:31
    关注

    Here's to help you get started:

    The base api URL is http://gdata.youtube.com/feeds/api/videos/VIDEO_ID?v=2&alt=json.

    <?php
    
    $video_data = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/a_kAUiJwRs0?v=2&alt=json"),true);
    
    echo $video_data['entry']['title']['$t']." is ".$video_data['entry']['media$group']['yt$duration']['seconds']." seconds long.";
    

    Output:

    Love, Fate, Love - Final Approach ED Single Love, Fate, Love Original Soundtrack is 283 seconds long.

    Replace a_kAUiJwRs0 with your video ID. You may print_r on $video_data to see all the values you get.

    Once you have their video ID, you may check if their duration (in seconds) is longer or shorter than 120 seconds, and reject or accept based on that.

    I would recommending reading this to see what video responses will have. (You can always var_dump to see exactly what it returns)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵