<tfoot id='rdUBB'></tfoot>
    • <bdo id='rdUBB'></bdo><ul id='rdUBB'></ul>

      1. <i id='rdUBB'><tr id='rdUBB'><dt id='rdUBB'><q id='rdUBB'><span id='rdUBB'><b id='rdUBB'><form id='rdUBB'><ins id='rdUBB'></ins><ul id='rdUBB'></ul><sub id='rdUBB'></sub></form><legend id='rdUBB'></legend><bdo id='rdUBB'><pre id='rdUBB'><center id='rdUBB'></center></pre></bdo></b><th id='rdUBB'></th></span></q></dt></tr></i><div id='rdUBB'><tfoot id='rdUBB'></tfoot><dl id='rdUBB'><fieldset id='rdUBB'></fieldset></dl></div>
      2. <legend id='rdUBB'><style id='rdUBB'><dir id='rdUBB'><q id='rdUBB'></q></dir></style></legend>

        <small id='rdUBB'></small><noframes id='rdUBB'>

        Youtube PHP APi 检查视频是否重复

        Youtube PHP APi Check VIdeo Is Duplicate Or Not(Youtube PHP APi 检查视频是否重复)

          <bdo id='9mJQD'></bdo><ul id='9mJQD'></ul>
              • <tfoot id='9mJQD'></tfoot>
                <i id='9mJQD'><tr id='9mJQD'><dt id='9mJQD'><q id='9mJQD'><span id='9mJQD'><b id='9mJQD'><form id='9mJQD'><ins id='9mJQD'></ins><ul id='9mJQD'></ul><sub id='9mJQD'></sub></form><legend id='9mJQD'></legend><bdo id='9mJQD'><pre id='9mJQD'><center id='9mJQD'></center></pre></bdo></b><th id='9mJQD'></th></span></q></dt></tr></i><div id='9mJQD'><tfoot id='9mJQD'></tfoot><dl id='9mJQD'><fieldset id='9mJQD'></fieldset></dl></div>

                <small id='9mJQD'></small><noframes id='9mJQD'>

                <legend id='9mJQD'><style id='9mJQD'><dir id='9mJQD'><q id='9mJQD'></q></dir></style></legend>
                    <tbody id='9mJQD'></tbody>
                  本文介绍了Youtube PHP APi 检查视频是否重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您好,我正在使用 Google PHP API 上传 PHP 视频.我遵循了本教程 来实现这一点,它工作正常.但是如果视频已经存在于我的频道中,它也会返回视频详细信息,但我找不到它因重复而被拒绝.

                  Hi I am using Google PHP API to upload video in PHP. I have followed this tutorial to implement this and it is working fine. But there is a problem if video is already exist in my channel it is also returning the video details and I can't find it is a rejected for duplicate.

                  所以我找不到这是一个重复的视频,如果它是重复的,那么主视频是什么.表示主视频的视频详细信息,从中将其作为副本进行比较.

                  So I cant find this is a duplicate video or not and if it is duplicate then what is the main video. Means the video details of main video from which it is compared as duplicate.

                  请帮我看看这是不是重复的视频?

                  Please help me to find this is a duplicate video or not?

                  推荐答案

                  我能想到的检查视频状态的唯一解决方案是使用表中的字段来标记视频是否已处理.然后将 cron 设置为每小时(或您想要的频率)运行以检查视频状态.

                  The only solution I could come up with to check the video status is to use a field in the table to mark the video as processed or not. Then set a cron to run every hour (or however often you want) to check the video status.

                  我的videos 表中的字段是processed.NULL 表示未处理,0 表示已处理.我的 api 字段以 json 格式存储 YouTube 的视频 ID.

                  The field in my videos table is processed. NULL for not processed, 0 if it's processed. My api field stores the YouTube's video ID in json format.

                  这是我的 cron 脚本:

                  Here's my cron script:

                  # Starts the YouTubeService.
                  $youtube_obj=new Google_Service_YouTube($client);
                  
                  # Get new uploaded videos from the database.
                  $unprocessed_videos=$db->get_results('SELECT `id`, `file_name`, `contributor`, `api` FROM `'.DBPREFIX.'videos` WHERE `processed` IS NULL');
                  
                  # If there are new videos...
                  if($unprocessed_videos>0)
                  {
                      # Loop through the new videos
                      foreach($unprocessed_videos as $new_video)
                      {
                          # Has the video been processed? Default is TRUE. will be changed to FALSE if the video still has "uploaded" status.
                          $video_processed=TRUE;
                  
                          # Decode the `api` field.
                          $api_decoded=json_decode($new_video->api);
                          # Get the YouTube Video ID.
                          $video_yt_id=$api_decoded->youtube_id;
                  
                          if(isset($new_video->file_name))
                          {
                              # Set the path to the video on the server.
                              $video_path='videos'.DS.$new_video->file_name;
                          }
                  
                          $to='uploaders email';
                          $reply_to='whomever';
                          $subject="Video status from ".DOMAIN_NAME;
                          $body='';
                  
                          # Check the video status.
                          $check_status=$youtube_obj->videos->listVideos('status', array('id' => $video_yt_id));
                  
                          # Did YouTube return results?
                          if(!empty($check_status['items']))
                          {
                              # Loop through the videos from YouTube.
                              foreach($check_status['items'] as $status)
                              {
                                  if($status['status']['uploadStatus']=="uploaded")
                                  {
                                      # The video has not been processed yet so do not send an email.
                                      $video_processed=FALSE;
                                  }
                                  # Check to see if the YouTube upload was a success.
                                  elseif($status['status']['uploadStatus']=="processed")
                                  {
                                      # Tell the user the video was uploaded.
                                      $body.='Your video has been uploaded to YouTube and can be viewed at http://'.FULL_DOMAIN.'media/videos/?video='.$new_video->id;
                                  }
                                  # Check if the uploaded video status is rejected.
                                  elseif($status['status']['uploadStatus']=="rejected")
                                  {
                                      if(isset($new_video->file_name))
                                      {
                                          # Get the Upload class.
                                          require_once 'Form'.DS.'Upload.php');
                                          # Instantiate an Upload object.
                                          $upload_obj=new Upload($video_path);
                                          # Delete video file from server.
                                          $upload_obj->deleteFile($video_path);
                  
                                          # Delete rejected video from YouTube
                                          $delete_response=$youtube_obj->videos->delete($video_yt_id);
                                      }
                  
                                      # Need to delete the entry from the database as well.
                                      $db->query('DELETE FROM `'.DBPREFIX.'videos` WHERE `id` = '.$db->quote($new_video->id).' LIMIT 1');
                  
                                      # Check if the rejection status was a duplicate.
                                      if($status['status']['rejectionReason']=="duplicate")
                                      {
                                          # Tell the user the video was a duplicate.
                                          $body.='Your video was rejected because it was a duplicate video';
                                      }
                                  }
                              }
                          }
                          else
                          {
                              $body.='Your video was not found on YouTube';
                              $video_processed=TRUE;
                          }
                          # Update database if the video has been "processed".
                          if($video_processed===TRUE)
                          {
                              # Get the Email class.
                              require_once 'Email'.DS.'Email.php');
                              # Instantiate a new Email object.
                              $mail_obj=new Email();
                              $mail_obj->sendEmail($subject, $to, $body, $reply_to);
                              # Set video to processed.
                              $db->query('UPDATE `'.DBPREFIX.'videos` SET `processed` = 0 WHERE `id` = '.$db->quote($new_video->id).' LIMIT 1');
                          }
                      }
                  }
                  

                  这篇关于Youtube PHP APi 检查视频是否重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <i id='xWre8'><tr id='xWre8'><dt id='xWre8'><q id='xWre8'><span id='xWre8'><b id='xWre8'><form id='xWre8'><ins id='xWre8'></ins><ul id='xWre8'></ul><sub id='xWre8'></sub></form><legend id='xWre8'></legend><bdo id='xWre8'><pre id='xWre8'><center id='xWre8'></center></pre></bdo></b><th id='xWre8'></th></span></q></dt></tr></i><div id='xWre8'><tfoot id='xWre8'></tfoot><dl id='xWre8'><fieldset id='xWre8'></fieldset></dl></div>

                  1. <legend id='xWre8'><style id='xWre8'><dir id='xWre8'><q id='xWre8'></q></dir></style></legend>

                      • <small id='xWre8'></small><noframes id='xWre8'>

                          • <bdo id='xWre8'></bdo><ul id='xWre8'></ul>
                            <tfoot id='xWre8'></tfoot>

                              <tbody id='xWre8'></tbody>