philippe44 / LMS-YouTube

Play YouTube videos on LMS
38 stars 15 forks source link

API implementation overhaul #2

Closed michaelherger closed 9 years ago

michaelherger commented 9 years ago

Hi Philippe,

here's my suggested refactor of all things Youtube API interaction:

Have fun :-)

philippe44 commented 9 years ago

Thanks Michael for the huge refactoring. It's at the same time fantastic but killing me as well :-). I'm so bad at Perl +LMS that it will take me a few days to understand all the modifications you've done while I was up-to-date with Triode's version. Don't get me wrong, this is really great, was much needed and could never have done it by myself... just a few extra headaches to come !

mherger commented 9 years ago

It's worth the effort, trust me :-P. The code imho is much cleaner, and easier to be re-used in other ways. Eg. the youtubechannel:// protocol handler you'd like to implement would call the same abstract API search call as in other places.

mherger commented 9 years ago

One more thing: don't try to understand change by change. Don't try to read the diff. It's basically a re-write of the navigation, there are too many changes. Just read the new code. I know, all those callbacks can be confusing. But once you've understood how the new code works, you won't bother reading the diff again.

philippe44 commented 9 years ago

I absolutely agree, and I will go through it, have no doubt ! One thing, I ran into an error that was already in my code. The region code cannot be a language code (works in some places like FR, but when language code is EN, it fails. Is there an API to get country vs language in LMS ?

mherger commented 9 years ago

No, country is not known in LMS at all.

philippe44 commented 9 years ago

yes, I've already ditched the whole old files. I'll understand firs the basic video search with the callback structure and then will expand from that. At least, I know what is the "intention" of the plugin where when I started I had no idea at all and that was a real nightmare, on top of the HTTPS and Perl inheritance system that was not clear to me

philippe44 commented 9 years ago

okay, for Country then it will be manual I dont' want to offend my UK friends or US friends :-)

mherger commented 9 years ago

You could have some reasonable default value per language, then let the user change it in the prefs. Eg. EN -> US, DE -> DE.

mherger commented 9 years ago

Are you Canadian or French?

philippe44 commented 9 years ago

French if I set EN-US, all the British community of LMS users are going to kill me - and they are many

philippe44 commented 9 years ago

that would be my last contribution to LMS

philippe44 commented 9 years ago

Although I'm still dreaming of Sonos synchro and bring back Rapshody (AES) to legacy devices, as we discussed a while ago, plus Amazon Echo integration and a nice 3D printed box for a Pi + screen

mherger commented 9 years ago

The code is supposed to be two letters only: "The regionCode parameter instructs the API to return search results for the specified country. The parameter value is an ISO 3166-1 alpha-2 country code."

https://www.iso.org/obp/ui/#search/code/

philippe44 commented 9 years ago

oh well I'll import the table and make some deduction, alphabetical order

philippe44 commented 9 years ago

wil let these as param anyway with the changes you've made, a channel can be a favorite as well ?

philippe44 commented 9 years ago

there is nothing LMS can query from the computer ? or perl ?

mherger commented 9 years ago

No, I haven't implemented a protocol handler for channels (see the forum thread)

philippe44 commented 9 years ago

like locale::country

mherger commented 9 years ago

I really wouldn't worry too much about the country. Really only do a mapping for the language codes which don't exist as a country. Most US users probably wouldn't see any difference if they were served EN results. And if they notice, then this probably teaches them a lesson :-)

philippe44 commented 9 years ago

that would be UK for result, no ? For the favorite, understood and I guess it will be easy after the work you have done

philippe44 commented 9 years ago

so thanks again, its getting awfully late for me as I've traveled east to west, so double trouble