sounds¶
Submodules¶
Exceptions¶
Generic exception for the module |
|
Generic exception for the module |
|
Generic exception for the module |
|
Generic exception for the module |
|
Generic exception for the module |
Classes¶
A client to interact with the Sounds API |
|
Create a collection of name/value pairs. |
|
An enum for valid image types for recipes |
|
Create a collection of name/value pairs. |
|
/v2/networks - Provides the list of all the v2 networks |
|
Represents a content category. |
|
Represents a collection container. |
|
Base container for organizing content - not directly playable. |
|
Base class for actual playable content. |
|
Represents a menu container with items. |
|
Represents a menu item container. |
|
Base class for actual playable content. |
|
Represents a podcast container (holds episodes). |
|
Represents a playable podcast episode. |
|
Base container for organizing content - not directly playable. |
|
Represents a playable radio clip. |
|
Represents a radio series container (holds episodes). |
|
Represents a playable radio show. |
|
Represents a recommended menu item. |
|
Represents a schedule for a given date. |
|
Represents a scheduled program item. |
|
Represents a segment within a stream. |
|
Represents a radio/media station. |
|
Represents a search result showing a station. Keys are different enough to warrant a separate model |
|
Represents a station stream. |
|
Create a collection of name/value pairs. |
Package Contents¶
- class sounds.SoundsClient(username: str | None = None, password: str | None = None, session: aiohttp.ClientSession | None = None, cookie_file_location: str | pathlib.Path = COOKIE_FILE, timezone: datetime.tzinfo | None = None, logger: logging.Logger | None = None, log_level: int | None = None, mock_session: bool = False, **kwargs)¶
A client to interact with the Sounds API
- username = None¶
- password = None¶
- login_details_provided = False¶
- current_station: sounds.models.Station | None = None¶
- current_stream: sounds.models.Stream | None = None¶
- current_segment: sounds.models.Segment | None = None¶
- timeout¶
- mock_session = False¶
- managing_session¶
- cookie_store¶
- auth¶
- schedules¶
- user¶
- requests¶
- streaming¶
- stations¶
- personal¶
- setLogger(log_level=None)¶
- async login() bool¶
Signs into BBC Sounds.
- Parameters:
username – The username or email address to sign in with
password – The password to sign in with
- Returns:
True if successfully logged in, False otherwise
- Return type:
- Raises:
LoginFailedError – If the login fails for any reason
UnauthorisedError – If the login is not authorised
- save_cookies()¶
- load_cookies()¶
Get the main Sounds menu.
- async logout()¶
- async close()¶
- class sounds.ContainerType¶
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- BRAND = 'brand'¶
- SERIES = 'series'¶
- ITEM = 'container_item'¶
- class sounds.ImageType¶
Bases:
enum.EnumAn enum for valid image types for recipes
- COLOUR = 'colour'¶
- COLOUR_DEFAULT = 'colour_default'¶
- BACKGROUND = 'background'¶
- BLOCKS_COLOUR = 'blocks_colour'¶
- BLOCKS_COLOUR_BLACK = 'blocks_colour_black'¶
- BLOCKS_COLOUR_WHITE = 'blocks_colour_white'¶
- class sounds.PlayStatus¶
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- STARTED = 'started'¶
- PAUSED = 'paused'¶
- ENDED = 'ended'¶
- HEARTBEAT = 'heartbeat'¶
- class sounds.URLs¶
Bases:
enum.Enum/v2/networks - Provides the list of all the v2 networks /v2/networks/playable - Provides the list of all the playable networks /v2/networks/{id}/playable - Provides the network playable item by network ID. <span>🎶</span> Green Day /radio/networks.json - All iPlayer Radio networks - contains business logic for masterbrand and service relationships /v2/services/{sid}/tracks/latest/playable - Retrieve list of tracks as playable items for a service <span>🎶</span> Deftones
- LOGIN_START = 'https://session.bbc.co.uk/session?ptrt=https%3A%2F%2Fwww.bbc.co.uk%2Fsounds&context=iplayerradio...¶
- LOGIN_START_I18N = 'https://account.bbc.com/auth?realm=%2F&clientId=Account&ptrt=https%3A%2F%2Fwww.bbc.com%2F&userOr...¶
- LOGIN_BASE = 'https://account.bbc.com'¶
- COOKIE_BASE = 'https://www.bbc.co.uk'¶
- COOKIE_BASE_I18N = 'https://www.bbc.com'¶
- JWT = 'https://rms.api.bbc.co.uk/v2/sign/token/{station_id}'¶
- INTL_JWT = 'https://web-cdn.api.bbci.co.uk/xd/media-token?{id_type}={id}'¶
- USER_INFO = 'https://www.bbc.co.uk/userinfo'¶
- MEDIASET = 'https://open.live.bbc.co.uk/mediaselector/6/select/version/2.0/mediaset/pc/vpid/{station_id}/for...¶
- EPISODE_MEDIASET = 'https://open.live.bbc.co.uk/mediaselector/6/select/version/2.0/mediaset/pc/vpid/{episode_id}'¶
- NETWORKS_LIST = 'https://rms.api.bbc.co.uk/radio/networks.json'¶
- STATIONS = 'https://rms.api.bbc.co.uk/v2/experience/inline/stations'¶
- LIVE_STATION_DETAILS = 'https://rms.api.bbc.co.uk/v2/experience/inline/play/{station_id}'¶
- STATION_DETAILS = 'https://rms.api.bbc.co.uk/v2/networks/{station_id}'¶
- STATION_PLAYABLE_DETAILS = 'https://rms.api.bbc.co.uk/v2/networks/{station_id}/playable'¶
- LIVE_STATION = 'https://www.bbc.co.uk/sounds/play/live:{station_id}'¶
- NOW_PLAYING = 'https://rms.api.bbc.co.uk/v2/services/{station_id}/segments/latest?limit={limit}'¶
- SCHEDULE = 'https://rms.api.bbc.co.uk/v2/experience/inline/schedules/{station_id}'¶
- SCHEDULE_DATE = 'https://rms.api.bbc.co.uk/v2/experience/inline/schedules/{station_id}/{date}'¶
- SEGMENTS = 'https://rms.api.bbc.co.uk/v2/versions/{vpid}/segments'¶
- PLAYABLE_ITEMS_CONTAINER = 'https://rms.api.bbc.co.uk/v2/programmes/playable?container={pid}&sort=sequential'¶
- CATEGORY_LATEST = 'https://rms.api.bbc.co.uk/v2/programmes/playable?category={category}&sort=-release_date&experien...¶
- CATEGORY_POPULAR = 'https://rms.api.bbc.co.uk/v2/programmes/playable?category={category}&sort=popular&experience=domestic'¶
- BROADCAST = 'https://rms.api.bbc.co.uk/v2/broadcasts/{pid}'¶
- PID = 'https://rms.api.bbc.co.uk/v2/programmes/{pid}'¶
- PID_PLAYABLE = 'https://rms.api.bbc.co.uk/v2/programmes/{pid}/playable'¶
- CONTAINER_URL = 'https://rms.api.bbc.co.uk/v2/experience/inline/container/{urn}'¶
- PLAYLIST = 'https://www.bbc.co.uk/programmes/{pid}/playlist.json'¶
- COLLECTIONS_FULL = 'https://rms.api.bbc.co.uk/v2/collections/{pid}/members/container?experience=domestic&offset={off...¶
- COLLECTIONS = 'https://rms.api.bbc.co.uk/v2/collections/{pid}/members/container?experience=domestic'¶
- CURATIONS = 'https://rms.api.bbc.co.uk/v2/curations/{pid}/members/playable?experience=domestic'¶
- EXPERIENCE_MENU = 'https://rms.api.bbc.co.uk/v2/my/experience/inline/listen'¶
- SEARCH_URL = 'https://rms.api.bbc.co.uk/v2/experience/inline/search?q={search}'¶
- SHOW_SEARCH_URL = 'https://rms.api.bbc.co.uk/v2/programmes/search/container?q={search}'¶
- EPISOSDE_SEARCH_URL = 'https://rms.api.bbc.co.uk/v2/programmes/search/playable?q={search}'¶
- PODCASTS = 'https://rms.api.bbc.co.uk/v2/experience/inline/speech'¶
- MUSIC = 'https://rms.api.bbc.co.uk/v2/experience/inline/music'¶
- NEWS = 'https://rms.api.bbc.co.uk/v2/experience/inline/container/urn:bbc:radio:category:news'¶
- exception sounds.APIResponseError¶
Bases:
SoundsExceptionGeneric exception for the module
- exception sounds.InvalidFormatError¶
Bases:
SoundsExceptionGeneric exception for the module
- exception sounds.LoginFailedError¶
Bases:
SoundsExceptionGeneric exception for the module
- exception sounds.NetworkError¶
Bases:
SoundsExceptionGeneric exception for the module
- exception sounds.NotFoundError¶
Bases:
SoundsExceptionGeneric exception for the module
- class sounds.Category¶
Bases:
ImageContainerRepresents a content category.
- class sounds.Collection¶
Bases:
ImageContainerRepresents a collection container.
- class sounds.Container¶
Bases:
BaseObject,IdentifiableMixinBase container for organizing content - not directly playable.
- sub_items: List[SoundsTypes] | None = None¶
- class sounds.LiveStation¶
Bases:
PlayableItem,IdentifiableMixin,ImageMixinBase class for actual playable content.
- class sounds.Menu¶
Bases:
SerializableMixinRepresents a menu container with items.
- get(key: str) MenuItem | RecommendedMenuItem | None¶
Get a menu item by ID.
- class sounds.MenuItem¶
Bases:
ImageContainerRepresents a menu item container.
- get(key: str) CategoryItemContainer | Container | LiveStation | PodcastEpisode | RadioClip | RadioShow | Segment | ScheduleItem | StationSearchResult | None¶
Get a sub-menu item by ID.
- class sounds.PlayableItem¶
Bases:
BaseObject,IdentifiableMixinBase class for actual playable content.
- start: datetime.datetime | None = None¶
- end: datetime.datetime | None = None¶
- is_live(timezone: zoneinfo.ZoneInfo | pytz.tzinfo.BaseTzInfo) bool¶
- has_already_aired(timezone: zoneinfo.ZoneInfo | pytz.tzinfo.BaseTzInfo) bool¶
- class sounds.Podcast¶
Bases:
ImageContainerRepresents a podcast container (holds episodes).
- class sounds.PodcastEpisode¶
Bases:
PlayableItem,ImageMixin,IdentifiableMixinRepresents a playable podcast episode.
- class sounds.PromoItem¶
Bases:
ContainerBase container for organizing content - not directly playable.
- item: PlayableItem¶
- class sounds.RadioClip¶
Bases:
PlayableItem,TimedContent,ImageMixin,IdentifiableMixinRepresents a playable radio clip.
- class sounds.RadioSeries¶
Bases:
ImageContainerRepresents a radio series container (holds episodes).
- class sounds.RadioShow¶
Bases:
PlayableItem,TimedContent,ImageMixin,IdentifiableMixinRepresents a playable radio show.
- property item_id¶
- class sounds.Schedule¶
Bases:
ContainerRepresents a schedule for a given date.
- sub_items: List[ScheduleItem] | None¶
- get_current_item(timezone: zoneinfo.ZoneInfo | pytz.tzinfo.BaseTzInfo = pytz.timezone('UTC')) ScheduleItem | None¶
Get the currently airing schedule item.
- class sounds.ScheduleItem¶
Bases:
ImageMixin,PlayableItemRepresents a scheduled program item.
- class sounds.Segment¶
Bases:
SerializableMixin,ImageMixinRepresents a segment within a stream.
- property spotify_url¶
- class sounds.StationSearchResult¶
Bases:
SerializableMixin,IdentifiableMixinRepresents a search result showing a station. Keys are different enough to warrant a separate model
- class sounds.Stream¶
Bases:
TimedContent,SerializableMixin,ImageMixinRepresents a station stream.
- class sounds.MenuRecommendationOptions¶
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- EXCLUDE = 'Exclude'¶
- INCLUDE = 'Include'¶
- ONLY = 'Only'¶