Giter Site home page Giter Site logo

Comments (4)

balloob avatar balloob commented on July 16, 2024

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.

jaapz avatar jaapz commented on July 16, 2024

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.

balloob avatar balloob commented on July 16, 2024

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.

jaapz avatar jaapz commented on July 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.