Problem/Motivation
YouTube has released a new API, disabling the previous APIs, breaking the code.
Proposed resolution
Adapt the code for the last API usage.
Remaining tasks
Apply the patch and commit!
Original report
Since yesterday i get this video in my Youtube Channel Block.
https://youtube.com/devicesupport
"Youtube is upgrading to a newer version, which is not supported by this device or app. To learn more and see where you can watch YouTube, visit www.youtube.com/devicesupport"
| Comment | File | Size | Author |
|---|---|---|---|
| #68 | upgrade_youtube_channel-2474977-68.patch | 8.22 KB | bendev |
| #66 | 2474977-66-upgrade-to-api-v3.1.patch | 9.61 KB | sothish |
| #66 | interdiff-2474977-51-66.txt | 3.97 KB | sothish |
| #52 | 2474977-52-upgrade-to-api-v3.1-d6.patch | 10.64 KB | delmonij |
| #51 | 2474977-51-upgrade-to-api-v3.1.patch | 7.06 KB | delmonij |
Comments
Comment #1
sokrplare commentedLooks like v2 of the YouTube API has been fully deprecated (http://youtube-eng.blogspot.com/2014/03/committing-to-youtube-data-api-v...) and this module would need to switch to v3 (https://developers.google.com/youtube/v3/) to continue working.
Comment #2
michel3 commentedsubscrive problem. an update in works?
Comment #3
fadeslayer commentedI encountered the same problem, I temporarily switched to custom block with iframe embed, waiting for the problem solution.
Comment #4
manmando commentedsame problem :P
Comment #5
markusgerlach commentedI got a message today its saying:
Could not fetch videos from youtube channel.
Comment #6
markusgerlach commentedSomeone planning to provide a Youtube API v3 version of this module?
Comment #7
just.andy.shilton commentedHi all,
Like you I came across the same "device support" message and realised what was going on. I'm not the module maintainer but I'm working on a fix it, in good Drupal spirit, sharing here seems to be the best place to post what I've found and what I'm working on.
The Issue
In short, the old YouTube API v2 has been deprecated. You can see that here:
https://developers.google.com/youtube/2.0/developers_guide_protocolIt was deprecated in March 2014 and switched off April 2015.The new API v3 does what we need it to, but it does require you to setup a developer account with Google and get an API key.
Findings so far to include in the patch
There is a JSON feed available, if you have an API key. To obtain an API key, you will need to follow the instructions here:
https://developers.google.com/youtube/v3/getting-startedIn short: Get a google account, goto the Developers Console here
https://console.developers.google.com/project, create a Project, under APIs, enable the YouTube Data API, then under Credentials Create a new API key. Grab this key cause we'll need itNote: The module needs extending to store this API key
Finding the right feed
The new API can be used to to find the upload feed ID using the following logic (I'm going to use BCfm's YouTube channel as the example here because it is the feed I'm working on).
Grab the URL of the channel:
https://www.youtube.com/channel/UClQzIwSpYAM2ZnelpiszXKw/feedExtract the channel ID: UClQzIwSpYAM2ZnelpiszXKw
Make a call to the YouTube APIv3 to get the "uploads" playlist ID by calling the following:
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UClQzIwSpYAM2ZnelpiszXKw&key={YOUR API KEY}You'll notice the id is used in the call, along with your API key.
In the returned feed, you will get
You can now use the ID for uploads to list them. The API paginates the results with a maximum of 50 per page.
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUlQzIwSpYAM2ZnelpiszXKw&key={YOUR API KEY}&maxResults=10If there are more results than ten, a "NextPageToken" is given (and likewise, when paging you get a "PreviousPageToken"). Appending this to the end of the feed moves the page. Add"&pageToken={NextPageToken}" to the end to move pages.
The result is a JSON feed with all the details we need to display the YouTube videos.
I'm working on patches, but anyone else who is, please post too. Soon as I have a working patch I'll add it here.
Current Thoughts
Comment #8
just.andy.shilton commentedOk, sorry, it took me a while to figure out how to make a patch file. This is also the first time I've done this so if I'm doing this wrong, please don't get mad, I'm just trying to help.
Attached is a patch file for testing. I've tested it with a few feeds and it seems to be working ok.
The biggest changes - you'll need a Google API Key and this patch uses the channel ID (from the URL) instead of the username.
Comment #9
sokrplare commentedLooking super promising - thanks for putting the work into this @d33jay!
A few minor items for feedback...
1) Might be worth doing some
!empty()checks before jumping down to data deep in the array so we don't get bad errors if the format ever changes - for example something like:2) Using
sprintf()to set the$pathvariable would be a bit cleaner.3) Spacing looks like it uses 4-spaces to indent instead of Drupal standard of 2 spaces.
4) Oh, and if you want to know the standard patch naming conventions see step 11 in https://www.drupal.org/node/707484
Like I said all minor but figured if you want feedback here it is! Very thankful you did the heavy lifting on this! Marking as "Needs Review" instead of "Needs Work" since none of these issues are show stoppers so lets get some folks trying it out!
Comment #10
just.andy.shilton commented@covenantd Thanks for the feedback. I had a feeling their might be a few things as I did it in a hurry this afternoon. Didn't know there was a patch naming standard either. Will make sure I use that in future.
I'll try and add the changes in if I get time tomorrow.
Comment #11
opstao commentedThe same error is displaying for users of the Media: Youtube module when Youtube Channel and/or Youtube Channel Block is not also being used.
Comment #12
markusgerlach commentedThis patch work for me.
First i try to add the patch throw shell with
/web/sites/all/modules/youtubechannel$ patch -p1 < youtubechannel.patchbut i got this error
then i edit the modul code and it works.
thx
Comment #13
novatek commentedThe patch #8 works for me, thx!
Comment #14
nupeossa commentedHello markusgerlach!
I have the same error as you,
You can edit the code explain how exactly?
exactly where in the module?
Thanks in advance
Comment #15
sokrplare commentedSee https://www.drupal.org/patch/apply - if you aren't familiar with Git, look at the links for how to apply on Windows/manually at the bottom of that article.
Comment #16
casiflis_ commentedWhich kind of API we have to use? Server API KEY; Navigator Key, Android, iOS..i patched the module and follow the instructions, but my module shows the same "devicesupport".
Comment #17
casiflis_ commentedIf i use the both links by d33jay
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id={MY CHANNEL ID}&key={YOUR API KEY}
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlis...{MY PLAYLIST ID}&key={YOUR API KEY}&maxResults=10
I obtain the videos list, but when I put the Key and the CHANNEL ID on the Module configuration, i cant get the videos.
Maybe one of you who the patched worked can upload the entire module patched for testing.
Comment #18
just.andy.shilton commented@castiflis2 if you are seeing the old feed you either haven't applied the patch correctly or you need to flush your cache to ensure your Drupal installation uses the new code.
The code in the patch is a completely different feed which uses JSON. The old feed didn't so if you see the old feed, see the instructions that covenantd posted for applying patches. For windows users I have noticed it often doesn't read the UPPERCASE of the readme file when applying the patch. The guides should help you get around this, but you could alternatively comment out the patching of the readme file while testing. I only updated the instructions.
For finding the correct API key, use the following steps:
1) Sign up to Google at https://accounts.google.com
2) Log in to your developer console at https://console.developers.google.com/project
3) Create a project and give a name (eg myyoutubechannel). Note, it takes a minute or two for the project in initiate. Just wait.
4) Under APIS & Auth->apis Click on YouTube Data API, then click ENABLE at the top
5) Under APIS & Auth->credentials Click Create New Key. When asked, click on Browser Key
6) OPTIONAL - You can restrict which websites can use this key by adding the domains you want to use the youtubechannel module with. For testing it probably isn't necessary but it would be good security to restrict the domains for live sites as your API key is exposed as part of the calls the module makes to YouTube. If the key works on any domain someone else could use it and use up your credits. You can edit this list later by coming back to this location and clicking "edit allowed referers".
This is the API key you need for this module. It is now a requirement to use the Youtube data API. (Unless someone wants to write an OAUTH version?).
Comment #19
casiflis_ commented@d33jay I have a patched module. @novatek sent me a patched module. (Thank you!)
I have the correct API and correct Channel ID, but I received a message saying "Please configure this section in the admin page".
I dont know where the problem is located, now i have this message.
Notice: Undefined offset: 0 en youtubechannel_getview() (line 105 de /home/myweb/www/sites/all/modules/youtubechannel/youtubechannel.module).
Steps I've done.
1) Edited manually the module and now i use a static link for hook the videos (with API kay and playlist), but the web shows the message below, the offset: 0 on that line.
Comment #20
just.andy.shilton commented@Castiflis2 could you post your YouTube channel ID, or send it to me privately? I can have a look at the difference then and see what is going on.
Comment #21
David Hernández commentedHere is a reroll of d33jay patch at #8. The previous patch wasn't applying due to being done on a git repository that wasn't a clone of the youtubechannel git repo.
I also have done some small changes so the code complies with the Drupal Code Standards: https://www.drupal.org/coding-standards
Comment #22
David Hernández commentedOk, there were some errors on the patch. Here is the correct one.
Comment #24
casiflis_ commentedPatch #22 worked fine to me.
Thank you guys for the time you inverted in this.
Comment #25
nupeossa commentedTank you David Hernández
Finally i can patch my module.
Comment #26
bendev commentedpatch #22 is working fine
thanks
Comment #27
just.andy.shilton commented@David Hernández Thank you mate. Bit new to patching and the like. Appreciate ya help :)
Comment #28
David Hernández commented@d33jay, no problem! Here is the documentation where explains how to create patches properly: https://www.drupal.org/node/1054616
Comment #29
kow commentedCan anyone attach the patched file?
Comment #30
sokrplare commentedComment #31
David Hernández commented@kow, please, don't hide the files. If you don't know how to apply a patch, here is the documentation: https://www.drupal.org/patch/apply
Also, don't delete the information of the issue summary if you are not going to add new valuable information.
Comment #32
David Hernández commentedComment #33
Rasti commentedI tried to patch it. i got this error :
user@domain.com[~/www/sites/all/modules/youtubechannel$ patch < 2474977-22-upgrade-to-api-v3.patch
patching file README.txt
patching file youtubechannel.admin.inc
patching file youtubechannel.info
Hunk #1 FAILED at 6.
1 out of 1 hunk FAILED -- saving rejects to file youtubechannel.info.rej
patching file youtubechannel.module
any one get same error.
Comment #34
David Hernández commented@Rasti, can you try to patch it using git?
user@domain.com[~/www/sites/all/modules/youtubechannel$ git apply 2474977-22-upgrade-to-api-v3.patchAnother question, are you using the last version of the module? The patch needs to be applied to the last dev version.
Comment #35
ksi commented@David Hernández
Thank you very much for your work. With the patch the playlist (small video thumbs) is back again.
But the embedded player is gone. The URL in iframe 'src' attribute is correct, but there is no generated YT code in the iframe part.
Does anybody have an advice for me?
Comment #36
just.andy.shilton commented@ksi I didn't change the iframe bit when I rewrote the code so it should just pull the new HTML5 player in. If it doesn't, firstly make sure you are getting videos - try another feed for example. Also check you have your width and height set.
If that still doesn't work, does it load in a different browser?
If it's still not working, could you post or private message me your channel ID and I'll have a look?
Comment #37
ksi commented@d33jay
Thank you very much for the great work (have seen now, you did the changes) and for your answer.
I've found the reason:
In the JS file
youtubechannel.jsthe line
jQuery('#youtubechannel-frame').attr('src','http://www.youtube.com/embed/' + youtubeid);is found. That does not work for HTTPS-sites. So the line has to be changed to:
jQuery('#youtubechannel-frame').attr('src','//www.youtube.com/embed/' + youtubeid);Comment #38
Rasti commented@David Hernández
I cant find the dev version. i applied the patch on: 7.x-2.1 tar.gz (9.53 KB) | zip (11.66 KB) 2014-Jun-22
when i use the git version on that one i get this
[~/www/sites/all/modules/youtubechannel$ git apply 2474977-22-upgrade-to-api-v3.patch
warning: youtubechannel.admin.inc has type 100644, expected 100755
error: patch failed: youtubechannel.info:6
error: youtubechannel.info: patch does not apply
warning: youtubechannel.module has type 100644, expected 100755
Comment #39
David Hernández commented@ksi, thanks for the update! I will provide a new patch soon.
@Rasti, that problem is caused because the permissions of the files of the module have changed. You can tell git to ignore those permissions with the next command:
git config core.filemode falseAfter that, you should be able to apply the patch.
If this doesn't work (I'm not really sure about that command), try to change the permissions to 755:
chmod 755 youtubechannel.admin.incYou can also try to download the dev version of the module and then, applying the patch:
git clone --branch 7.x-2.0 http://git.drupal.org/project/youtubechannel.gitComment #40
David Hernández commentedOk, new patch uploaded to fix the error reported by @ksi at #37. That problem only affected users who are using the module under HTTPS.
Comment #41
just.andy.shilton commented@ksi Ah yes, that would make total sense. Sorry, I'm wasn't testing on SSL for it to have shown up.
@David Hernandez, thanks for patching. I will give it a test on SSL this weekend if I can and feedback.
Comment #42
Rasti commented@David Hernández
Thanks I download the version you gave me and i applied the latest patch.
But turn out the channel I am using wont accept it. i believe cause of the channel Id.
I tried with this : https://www.youtube.com/user/ancientsocieties (didn't work)
getting this error :
Notice: Undefined offset: 0 en youtubechannel_getview().....
but i tried with this : https://www.youtube.com/channel/UCPWQWav6BpPvtanCtloXkiw (worked fine)
Comment #43
just.andy.shilton commented@Rasti - this patch requires that you use channel ID. It won't work with a channel name. When I started playing around with channel names it caused lots of errors, whereas the ID is exact. Make sure you setup your module using the channel ID and you should be fine.
Comment #44
Rasti commented@d33jay
To whom may concern and have same issue I had. as @d33jay said this patch is only work with channel ID and User ID, not channel name or user name.
Therefore if you are on a channel or user page in youtube, that uses name instead of ID. here the way to obtain the ID.
View the source code of channel page or user page and find the "data-channel-external-id=" what ever come next to that is the ID.
Comment #45
just.andy.shilton commentedI did some searching and have found the following page that details the API calls to get the IDs of channels. It maybe possible to add this into the module. The biggest point to note though, as Google state on the page, is that not every YouTube channel has a unique username so if we add it in we'll need to be mindful of this.
https://developers.google.com/youtube/v3/guides/working_with_channel_ids
I'm testing the following :
https://www.googleapis.com/youtube/v3/channels?key={YOUR_API_KEY}&forUsername={USER_NAME}&part=idComment #46
David Hernández commentedWhat @d33jay is propossing at #45 seems interesting, but I think it should be in a Feature request in a new issue.
Comment #47
arthitst commentedThank you all
That 's work.
Comment #48
just.andy.shilton commentedCan also confirm I have it working on both SSL and non.
Would be good to get some more feedback from the rest of you so we can perhaps move it to RTBTC and perhaps get it into the module as the current version is useless now the old feed has gone.
Has anyone else managed to successfully test the patch?
Comment #49
spanners commentedHello. I tried the above patch just by copying the patch file into the youtubechannel directory in modules and then "patch < 2474977-40-upgrade-to-api-v3.patch"
I get the following.
I punch in js/youtubechannel.js and then I get...
I checked the Youtube Channel admin settings and the new fields are there for API and Channel ID. I punch in the credentials I am certain are correct, but the published block just says "Please configure this section in the admin page".
I have added my website's address to the list of referrers on my API project.
Any help getting the videos displaying would be greatly appreciated. Have I patched the module correctly?
Comment #50
delmonij commentedI had good luck with 2474977-40-upgrade-to-api-v3.patch but need to save api usage on a busy site. This is just a tiny patch to the api urls. Thanks https://www.drupal.org/u/david-hern%C3%A1ndez for the real work!
This version had a typo fixed in next comment
Comment #51
delmonij commentedComment #52
delmonij commentedThis d6 version removes the "theme" functionality and is pretty much identical to to 7.x version.
Comment #53
eng_ismail commentedHello. I tried the above patch.
the error i got ""Sorry, there are no videos available on this channel.""
Comment #54
delmonij commentedTry to edit the module settings to include your v3 api "youtube_id"(v3 UID) and set "channel_id"(channel ID) and then you may have to clear cache / boost cache.
You can find your channel_id by looking at the source of your "upload page" for this tag data-channel-external-id="UCjXfkj5iarKHJrhYfeF9ZGg"... If the problem continues please try to uninstall/reinstall the module
Comment #55
eng_ismail commented@delmonji thank u bro it's work when i do it manually ,,,
but there's a problem that the API key is ACTIVE only one day and then will be inactive :( So , what i should to do ???
or i must billing before ?? is there another way to make it activate all the time ??
Thx in advance :D
Comment #56
eng_ismail commentedhello everyone,,
Please i need your help ,, i do all the step and add the patch ,, everything work fine on localhost machine
but when i upload these change on the server side it's not working and give me this message "Please configure this section in the admin page"
So, what i forget to do ??
Please help,
Thx in advance :D
Comment #57
David Hernández commented@eng_ismail, my guess is that you haven't configured the module on the server. The configuration of the module is stored on the database, so just uploading the changes from your local machine is not enough.
Comment #58
eng_ismail commented@david Hernandez , thx alot man for ur reply,
First, i remove the old " youtube channel module" on the server then upload the new one,
Second i put the path static "api_key" and "channel_id"
so, what i must to do on the database server to get it work ??
Thx bro in advance :D
Comment #59
David Hernández commented@eng_ismail, just go to the administration page of the module ( admin/config/services/youtubechannel ) and configure it as you did on your local machine.
Comment #60
eng_ismail commented@David Hernández, thx for ur reply,
I did as you send exactly and still the same message appear :(
And do all possible things and it's not working :(
Any help please
Comment #61
eng_ismail commented@David Hernández good afternoon ;)
I can handle the error now it's come from the server side ,, i got this error message "Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?" and i contact the server manager and he told me he can't enable this extension because of the security issue .. and please note that the V2 of youtube api it was work fine so, do you think is there any other way to make it work ???
Thx in advance :d
Comment #62
just.andy.shilton commented@eng_ismail - if you cannot use SSL from your server, try changing the YouTube URLs in the settings to NOT use SSL. To do this, change the HTTPS:// to HTTP:// This new module should support both now.
The YouTube API v2 is dead and the methods it used no longer valid so you need the new patches and to use API V3.
Comment #63
karbou commentedI have the same problem like @eng_ismail "Please configure this section in the admin page" but in localhost and in my server. I don't understand where is the probleme. I patch youtubechannel with this commande "patch -p1 < 2474977-22-upgrade-to-api-v3.patch, I had just one error with youtube channel.info at the line 10 but i add "configure = admin/config/services/youtubechannel" in this file.
Thanks for help
Comment #64
David Hernández commentedPlease, don't hide the last patches as is the last version where people might be working.
Comment #65
karbou commentedSorry it's not intentional
Comment #66
sothish commentedThanks @delmonij, #54 works fine for me. Please find the attached files, Some more minor changes are added in this interdiff.
Comment #67
xenophyle commentedThis patch worked for me, although for some reason I needed to apply it manually.
Comment #68
bendev commentedreroll patch to make it installable with drush make
Comment #69
nitinsp commented2474977-66-upgrade-to-api-v3.1.patch #66 its working fine for me.
Comment #70
nitinsp commentedComment #73
realEuph commentedI tried to install the patch in #66 to 7.x-2.1 after a clean download. I used the instructions at https://www.drupal.org/patch/apply (patch -p1 < 2474977-66-upgrade-to-api-v3.1.patch) [patch -p1 < 2474977-66-upgrade-to-api-v3.1.patch] when in the module's directory.
I get the following:
youtubechannel.info.rej
youtubechannel.module.rej