Comments (4)
A whole submodule would be too much and would create a lot of different modules when it grows. A better place would be a new util package.
Even after moving them to the util package I prefer to keep them being imported into pychromecast root so that you can do something like this:
import pychromecast pychromecast.play_youtube_video("VIDEO_ID")
from pychromecast.
But I don't think that's a really nice API. If in the future there might be gmusc specific stuff, that helper (in this API scheme) would look like `pychromecast.play_gmusic_song("SONG_ID"). I personally just don't like having all these different helpers in one module.
Encapsulating helpers for one app into one module feels cleaner and more organised, and seems a bit more logical API too.
Moving them from util into something else and still importing them directly into pychromecast isn't really fixing anything, the API will still be the same.
pychromecast.youtube.play_video()
pychromecast.gmusic.play_song()
This API scheme makes it clear that everything in the pychromecast.youtube
or pychromecast.gmusic
namespace will only work on their respective apps.
from pychromecast.
Pushing everything into submodules is not making life easier for the user. Currently the most used use cases are imported into the init so people don't have to look too far how to use it.
If a cleaner API would be our goal it would mean we end up in a Java-like landscape requiring users write code like pychromecast.config.APP_ID["HOME"]
, cast.get_protocol(pychromecast.websocket.PROTOCOL_RAMP)
or catch the error pychromecast.error.NoChromecastFoundError
. It's not very pythonic.
Next to that, Google has moved away from using DIAL when they released the official SDK of the Chromecast at the beginning of this year. This means that except for the initial batch of apps we are unable to retrieve the current running app. All communication happens now by a yet unknown protocol. Because of this I consider the chance of getting more of these methods very slim.
from pychromecast.
Actually you would then not do import pychromecast
but instead from pychromecast.error import NoChromecastFoundError
, which IMHO is nicer. But this is largely my preferred coding style so if you think that's not the way to go, it's your call 👍
from pychromecast.
Related Issues (20)
- ValueError: too many values to unpack (expected 5)
- Discovery doesn't work in an async context HOT 4
- Data difference when using GoogleTV Youtube vs Casting
- Custom http headers
- Idle chromecast custom screen example
- Command feedback
- Detect tv is on or off
- SiriusXM/Chromecast Casting Issue HOT 8
- Cannot initialize 'Chromecast' class HOT 2
- Not working with updated modules ('str' object has no attribute 'cast_type') HOT 1
- How to know if a specific connected TV is compatible ? HOT 1
- BBC Sounds conroller stopped working HOT 3
- Python 3.10 Depreciation Warning ssl.SSLContext()
- How to work with spotify HOT 5
- BBC iPlayer Live Stream - unable to get working
- Join existing chromecast session without interrupting it?
- pychromecast entering spin loop when a cast device reboots [if browser.stop_discovery() was called] HOT 2
- Mocking Chromecast?
- How to handle AssertionError for assert self.socket is not None?
- WARNING:pychromecast.controllers:SEEK command requested but no session is active HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pychromecast.