chunkysteveo / OctoPrintAPI

Library for use with Arduino compatible micro controllers (web enabled) to access the Octoprint API on Raspberry Pi's running the Octoprint 3D printer web server by the brilliant Gina Häußge, aka @foosel.
GNU General Public License v2.0
42 stars 24 forks source link

Conflict OctoprintAPI and YoutubeApi #35

Closed Egalistel closed 3 years ago

Egalistel commented 3 years ago

hello and already a big thank you for this bookstore. As part of a lametric project I am trying to combine different displays from insta, youtube and octoprint on a led matrix. But I am encountering a conflict issue between the youtube api and octoprint. During requests I receive this kind of message:

egametric_teste_octoprint:232:14: error: 'class YoutubeApi' has no member named 'printJob' subs = api.printJob.progressCompletion; ^ exit status 1 conflicting declaration 'OctoprintApi api' [13:47] egametric_teste_octoprint:200:14: error: 'class OctoprintApi' has no member named 'channelStats' subs = api.channelStats.subscriberCount; ^ exit status 1 conflicting declaration 'YoutubeApiapi'`

the 2 libraries seem to come into conflict with each other and for the moment the only solution is to have to make a choice between displaying one or the other. Is there a trick or a fix coming up to make the 2 work together?

Thanking you in advance for your response and your work.

chunkysteveo commented 3 years ago

Hmm. There's no plan to make the two compatible. But they both use the name 'api' in their examples. I am guessing that's where they are getting confused. You should rename your declaration api of either library from 'api' to 'opapi' or 'ytapi'. Find and replace could help there in your sketch! You shouldn't have to touch the libraries - just amend your sketch so each call to each library has a unique name.

Hope that helps!

fmatray commented 3 years ago

Hello, You should have a compilation error.

As @chunkysteveo suggest, just rename your variables : OctoprintApi octoprint_api(client, ip, octoprint_httpPort, octoprint_apikey);
YoutubeApi youtube_api(API_KEY, client);

There is another way with namespaces if you REALLY need to keep those names but it's harder and less readable.

Last idea, cleaner if you have a huge code, create 2 classes:

class MyYoutube { public: void begin() { api = new youtube_api(API_KEY, client); }; .... private: YoutubeApi *api; }

class MyOctoprint { public: void begin() { api = new OctoprintApi(API_KEY, client); };

.... private: OctoprintApi *api; }

Egalistel commented 3 years ago

A BIG big thank you, because yes it was so obvious. the name change was enough for the compilation to go smoothly. sorry for this question which seems to you it was silly. This is my very first project with an arduino, I had never coded this before :) I will be able to continue the project which should suddenly display the youtube subscription counter, insta, the time, the temperature and now thanks to your speed, the percentage of print, the time spent and remaining :) Sorry for my poor English, but being French, thank you google trad: p

chunkysteveo commented 3 years ago

Glad we can help, it took me a while to realise what you were doing - this is a big project if you're just getting started - impressed! Good luck with it! Guessing you're using an LED matrix?!

Best of luck with the project!!

Egalistel commented 3 years ago

there will be 2 versions, which will be a little more for me with a large size with a flexible 32x8 pixel banner and used mainly as video decoration, and a second more compact with 8x8 dot rgb matrix

I was really stuck on this part, so it will be finished soon, I do not know if there is a particular place that lends itself to sharing, but if the final project interests you, there is no problem for show a preview :)

when everything is really good the code will be available :)

karim60160 commented 3 years ago

Hello, I allow myself to solicit you because currently I work on the metric mentioned above. I block on the fact that youtube and instagram uses wificlient secure while octoprint uses only wificlient. do you have an idea to suggest to me. In advance thank you for your response