witnessmenow / arduino-youtube-api

A wrapper around the youtube api for arduino
MIT License
141 stars 48 forks source link

Youtube API not working #19

Closed timedin-de closed 4 years ago

timedin-de commented 4 years ago

Hey, I know its been a long time since the last post, but i have a problem. So i have this code (see attachment) and i noticed problems when using static ip adresses (in the code config and on the router side. Help is much appreciated. i get no error messages but "api.getChannelStatistics(CHANNEL_ID)" returns always false.

API token and url works fine ex.zip

(Sorry for my bad english)

AntoniousUA commented 4 years ago

Have same issue. Made _debug (in YoutubeApi.h ) as true and see in Serial monitor that body have all data, but parsing do not working.

17:06:19.195 -> .... connected to server 17:06:19.463 -> Body: 17:06:19.463 -> 1eb 17:06:19.463 -> { 17:06:19.463 -> "kind": "youtube#channelListResponse", 17:06:19.463 -> "etag": "RTeYeWoPiruQYgKMNGG_kd3IarM", 17:06:19.463 -> "pageInfo": { 17:06:19.463 -> "totalResults": 1, 17:06:19.463 -> "resultsPerPage": 1 17:06:19.463 -> }, 17:06:19.463 -> "items": [ 17:06:19.463 -> { 17:06:19.463 -> "kind": "youtube#channel", 17:06:19.463 -> "etag": "EJ5vRl7NExNelQlFhUk3HEOhLfE", 17:06:19.510 -> "id": "UCh7RTc1g64bJLwbzP8HXmMw", 17:06:19.510 -> "statistics": { 17:06:19.510 -> "viewCount": "73345", 17:06:19.510 -> "commentCount": "0", 17:06:19.510 -> "subscriberCount": "842", 17:06:19.510 -> "hiddenSubscriberCount": false, 17:06:19.510 -> "videoCount": "49" 17:06:19.510 -> } 17:06:19.510 -> } 17:06:19.510 -> ] 17:06:19.510 -> } 17:06:19.510 -> 17:06:19.510 -> 0 17:06:19.510 -> 17:06:19.510 -> 17:06:19.510 -> END 17:06:19.510 -> Closing client

dchadev commented 4 years ago

Same as above for me.

With debug enabled, in the serial monitor shows that it fetches correctly the data but it doesn't send anything to the displays.

Everything was working just fine up until a couple of days ago.

For reference, I was using this library with the sketch here: https://www.instructables.com/id/YouTube-Subscriber-Counter-With-ESP8266-V2/

kuuriisuu commented 4 years ago

Same as @dchadev, I have been using a modified version of the sketch at https://www.instructables.com/id/YouTube-Subscriber-Counter-With-ESP8266-V2/ since September 2019, with the same issue starting at the same time.

I can see a relatively large spike in API traffic before it crashed. Not particularly useful as a clue, but interesting nonetheless. Screen Shot 2020-05-15 at 4 55 37 PM

FusionSource commented 4 years ago

I am having the same issue, it was working fine, then just stopped a few days ago, been trying to figure it out, the only thing I have thought of is in the code for the ESP8266 board, you have to set the client to client.setInsecure(); this might have something to do with it. I have code written in c# for my mobile phone and this still works.

dchadev commented 4 years ago

@FusionSource I tried that the other day and it didn't solve the problem with the sketch I was using. It's weird because the library correctly gets the data from youtube and the backpack library works just fine showing on the displays whatever else I throw at them, but it's like if these two parts of the code don't communicate with each other anymore.

InterlinkKnight commented 4 years ago

So apparently everybody is having the same problem. I'm using it with the ESP32 without the client.setInsecure(); and still got the same problem.

You think the problem could be the ArduinoJson? We all had to use the version 5 because the version 6 didn't work.

dchadev commented 4 years ago

@InterlinkKnight That would be my (uneducated) guess, after the tests I've made so far. But I might be wrong as my knowledge about the ArduinoJson library pretty much equals zero for further investigation into that.

InterlinkKnight commented 4 years ago

Someone found the solution: https://www.youtube.com/watch?v=f4YXnHfK6ZM

I don't understand why it happened, but apparently it works. I say "apparently" because I decided to skip that library all together, for several reasons:

So my solution was to get the youtube API directly in the sketch, which solved all the problems I mentioned. I'll share my code later on my youtube channel.

witnessmenow commented 4 years ago

This had nothing to do with ArduinoJson V5 or V6, you can see in the @AntoniousUA serial output , in the body, there is a 1eb before the JSON starts that should not be there, the body is passed into Arduino JSON and with the 1eb before it was not valid JSON and it failed to parse.

I'm not sure what changed on YouTube/Googles end to make that happen, but that was not coming before last week.

This is fixed in #23, this is basically a complete re-write of the library to be way more memory efficient and to use ArduinoJsonV6