weixin_39604557
2021-01-01 14:35 阅读 1

Can we get thumbnail of video from youtube?

Instead of uploading video thumbnail our self, can we get thumbnails of video uploaded on youtube? As sometime user don't have specific thumbnail of video so in that case if we can ask youtube to generate and give us the link of that thumbnail? Any help regarding this will be appreciated, thanks!

该提问来源于开源项目:joedawson/youtube

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

20条回答 默认 最新

  • weixin_39679468 weixin_39679468 2021-01-01 14:35

    I'll need to look into this. I think this might not be possible as I think YouTube creates the thumbnails after/during the processing of the upload.

    I may be wrong, but will need to look into this.

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:35

    yes you are right that youtube creates thumbnail after processing. but we have video id and if we can use video id after processing to get thumbnails created.

    I'm also searching it. Thanks for your quick response and help.

    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:35

    You could try using this package to get the thumbnails after the upload :)

    https://github.com/alaouy/Youtube

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:35

    Thanks. Trying it and will inform you if it works,

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:35

    I'm getting following error on Youtube.php (line 42)

    Google API key is Required, please visit https://console.developers.google.com/
    

    I've already given GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET for your library so where do i find this key?

    And also this library create YouTube.php in config folder so will it create any issue/conflict with your library?

    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:35

    Sounds like there's a conflict. Do you have this?

    php
    use Youtube; // References Dawson\Youtube\Facades\Youtube;
    use Alaouy\Youtube\Facades\Youtube;
    

    If so, they're the same - therefore are conflicting.

    Change this:

    php
    use Alaouy\Youtube\Facades\Youtube
    

    To this:

    php
    use Alaouy\Youtube\Facades\Youtube as YoutubeInfo
    

    Then you can use all of the https://github.com/alaouy/Youtube methods with YoutubeInfo instead of Youtube (for uploading).

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:35

    Changed it but still getting API key required issue. What about /config/youtube.php file?

    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:35

    Hmm, I just took a look at https://github.com/alaouy/Youtube again. We both use the same filename for the config (config/youtube.php).

    With your existing youtube.php file, add a new key for the alaouy/Youtube package.

    php
    'key' => 'YOUR_API_KEY'
    
    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:35

    Sounds like you also want to create an API key on the Google Developer Console to use with this too.

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:35

    which key i've to give here? GOOGLE_CLIENT_ID?

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:35

    you are talking about this key? http://prntscr.com/g0fv14

    I've given that in 'key' => 'api key here', but nothing changed.

    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:36

    I think this is an individual API key, you can create one by visiting here: https://console.developers.google.com/apis/credentials

    Then create a new API key.

    screen shot 2017-07-26 at 10 35 50

    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:36

    Is that the correct project?

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:36

    yes it's correct project. I'm using it's OAuth 2.0 client IDs for your library and trying to use API keys but didn't work.

    Error is coming on youtube.php line # 42. And this line says:

    'developer_key' => env('GOOGLE_DEVELOPER_KEY', null),
    

    added it in env file too:

    GOOGLE_DEVELOPER_KEY=AIzaSyDfW91-xxxxxxxxxx
    
    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:36

    The error you're talking about isn't from this package though, it's from here:

    https://github.com/alaouy/Youtube/blob/master/src/Youtube.php#L43

    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:36

    Could you show me your config/youtube.php file?

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:36

    Here it is:

    return [
    
    /**
     * Application Name.
     */
    'application_name' => 'Your Application',
    
    /**
     * Client ID.
     */
    'client_id' => env('GOOGLE_CLIENT_ID', null),
    
    /**
     * Client Secret.
     */
    'client_secret' => env('GOOGLE_CLIENT_SECRET', null),
    
    /**
     * Access Type
     */
    'access_type' => 'offline',
    
    /**
     * Approval Prompt
     */
    'approval_prompt' => 'auto',
    
    /**
     * Scopes.
     */
    'scopes' => [
        'https://www.googleapis.com/auth/youtube',
        'https://www.googleapis.com/auth/youtube.upload',
        'https://www.googleapis.com/auth/youtube.readonly'
    ],
    
    /**
     * Developer key.
     */
    'developer_key' => env('GOOGLE_DEVELOPER_KEY', null),
    
    /**
     * Route URI's
     */
    'routes' => [
    
        /**
         * The prefix for the below URI's
         */
        'prefix' => 'youtube',
    
        /**
         * Redirect URI
         */
        'redirect_uri' => 'callback',
    
        /**
         * The autentication URI
         */
        'authentication_uri' => 'auth',
    
    ]
    
    ];
    
    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:36

    Ok, as the error says for https://github.com/alaouy/Youtube - an API key is required. I can't see that on your config?

    As the alaouy/Youtube package is looking for a key in config/youtube.php.

    Add in after developer_key or something.

    php
    'developer_key' => env('GOOGLE_DEVELOPER_KEY', null),
    
    /**
     * API Key for the "alaouy/Youtube" package.
     */
    'key' => 'THE API KEY YOU CREATED BEFORE',
    
    点赞 评论 复制链接分享
  • weixin_39679468 weixin_39679468 2021-01-01 14:36

    Also closing as obtaining thumbnails on uploaded videos are not supported with this package, but still happy to assist you with setting up alaouy/Youtube :)

    点赞 评论 复制链接分享
  • weixin_39604557 weixin_39604557 2021-01-01 14:36

    I've tried that too just like you said but nothing changed. If you hardcode key in constructor then it don't give this error (another SSL error is thrown which i guess has some other issue). Anyhow thanks for your time and help it put on right path :)

    点赞 评论 复制链接分享

相关推荐