Docstring cleanup (#665)

* Cleaned up docstrings

* cleaned up more

---------

Co-authored-by: sigma67 <sigma67.github@gmail.com>
This commit is contained in:
Hendrik Horstmann 2024-12-17 21:35:44 +01:00 • committed by GitHub
commit bb4bf4d3e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 43 additions and 43 deletions

View file

@ -127,7 +127,7 @@ reached at least the ``limit`` parameter, and return all of these results.
Which values can I use for languages? Which values can I use for languages?
************************************* *************************************
The `language` parameter determines the language of the returned results. The ``language`` parameter determines the language of the returned results.
``ytmusicapi`` only supports a subset of the languages supported by YouTube Music, as translations need to be done manually. ``ytmusicapi`` only supports a subset of the languages supported by YouTube Music, as translations need to be done manually.
Contributions are welcome, see `here for instructions <https://github.com/sigma67/ytmusicapi/tree/master/ytmusicapi/locales>`__. Contributions are welcome, see `here for instructions <https://github.com/sigma67/ytmusicapi/tree/master/ytmusicapi/locales>`__.

View file

@ -4,7 +4,7 @@ Tests use the ``unittest`` framework. Each function has a corresponding unittest
Sometimes there is a single unittest for multiple functions to ensure there are no permanent changes in the user's Sometimes there is a single unittest for multiple functions to ensure there are no permanent changes in the user's
YouTube account (i.e. subscribe and unsubscribe). YouTube account (i.e. subscribe and unsubscribe).
Note that there must be a ``browser.json`` and ``oauth.json`` in the `tests` folder to run all authenticated tests. Note that there must be a ``browser.json`` and ``oauth.json`` in the ``tests`` folder to run all authenticated tests.
These two files can be easily obtained as the default outputs of running the following commands respectively: These two files can be easily obtained as the default outputs of running the following commands respectively:
.. code-block:: bash .. code-block:: bash

View file

@ -51,9 +51,9 @@ class OAuthCredentials(Credentials):
proxies: Optional[dict] = None, proxies: Optional[dict] = None,
): ):
""" """
:param client_id: Optional. Set the GoogleAPI client_id used for auth flows. :param client_id: Optional. Set the GoogleAPI ``client_id`` used for auth flows.
Requires client_secret also be provided if set. Requires ``client_secret`` also be provided if set.
:param client_secret: Optional. Corresponding secret for provided client_id. :param client_secret: Optional. Corresponding secret for provided ``client_id``.
:param session: Optional. Connection pooling with an active session. :param session: Optional. Connection pooling with an active session.
:param proxies: Optional. Modify the session with proxy parameters. :param proxies: Optional. Modify the session with proxy parameters.
""" """
@ -112,10 +112,10 @@ class OAuthCredentials(Credentials):
def refresh_token(self, refresh_token: str) -> BaseTokenDict: def refresh_token(self, refresh_token: str) -> BaseTokenDict:
""" """
Method for requesting a new access token for a given refresh_token. Method for requesting a new access token for a given ``refresh_token``.
Token must have been created by the same OAuth client. Token must have been created by the same OAuth client.
:param refresh_token: Corresponding refresh_token for a matching access_token. :param refresh_token: Corresponding ``refresh_token`` for a matching ``access_token``.
Obtained via Obtained via
""" """
response = self._send_request( response = self._send_request(

View file

@ -117,8 +117,8 @@ class RefreshingToken(OAuthToken):
Method for CLI token creation via user inputs. Method for CLI token creation via user inputs.
:param credentials: Client credentials :param credentials: Client credentials
:param open_browser: Optional. Open browser to OAuth consent url automatically. (Default = False). :param open_browser: Optional. Open browser to OAuth consent url automatically. (Default: ``False``).
:param to_file: Optional. Path to store/sync json version of resulting token. (Default = None). :param to_file: Optional. Path to store/sync json version of resulting token. (Default: ``None``).
""" """
code = credentials.get_code() code = credentials.get_code()

View file

@ -284,8 +284,8 @@ class BrowsingMixin(MixinProtocol):
:param channelId: browseId of the artist as returned by :py:func:`get_artist` :param channelId: browseId of the artist as returned by :py:func:`get_artist`
:param params: params obtained by :py:func:`get_artist` :param params: params obtained by :py:func:`get_artist`
:param limit: Number of albums to return. `None` retrieves them all. Default: 100 :param limit: Number of albums to return. ``None`` retrieves them all. Default: 100
:param order: Order of albums to return. Allowed values: 'Recency', 'Popularity', 'Alphabetical order'. Default: Default order. :param order: Order of albums to return. Allowed values: ``Recency``, ``Popularity``, `Alphabetical order`. Default: Default order.
:return: List of albums in the format of :py:func:`get_library_albums`, :return: List of albums in the format of :py:func:`get_library_albums`,
except artists key is missing. except artists key is missing.
@ -469,7 +469,7 @@ class BrowsingMixin(MixinProtocol):
Get an album's browseId based on its audioPlaylistId Get an album's browseId based on its audioPlaylistId
:param audioPlaylistId: id of the audio playlist (starting with `OLAK5uy_`) :param audioPlaylistId: id of the audio playlist (starting with `OLAK5uy_`)
:return: browseId (starting with `MPREb_`) :return: browseId (starting with ``MPREb_``)
""" """
params = {"list": audioPlaylistId} params = {"list": audioPlaylistId}
response = self._send_get_request(YTM_DOMAIN + "/playlist", params) response = self._send_get_request(YTM_DOMAIN + "/playlist", params)
@ -760,7 +760,7 @@ class BrowsingMixin(MixinProtocol):
Gets related content for a song. Equivalent to the content Gets related content for a song. Equivalent to the content
shown in the "Related" tab of the watch panel. shown in the "Related" tab of the watch panel.
:param browseId: The `related` key in the `get_watch_playlist` response. :param browseId: The ``related`` key in the ``get_watch_playlist`` response.
Example:: Example::
@ -840,7 +840,7 @@ class BrowsingMixin(MixinProtocol):
""" """
Returns lyrics of a song or video. Returns lyrics of a song or video.
:param browseId: Lyrics browse id obtained from `get_watch_playlist` :param browseId: Lyrics browse id obtained from ``get_watch_playlist``
:return: Dictionary with song lyrics. :return: Dictionary with song lyrics.
Example:: Example::
@ -881,11 +881,11 @@ class BrowsingMixin(MixinProtocol):
def get_signatureTimestamp(self, url: Optional[str] = None) -> int: def get_signatureTimestamp(self, url: Optional[str] = None) -> int:
""" """
Fetch the `base.js` script from YouTube Music and parse out the Fetch the `base.js` script from YouTube Music and parse out the
`signatureTimestamp` for use with :py:func:`get_song`. ``signatureTimestamp`` for use with :py:func:`get_song`.
:param url: Optional. Provide the URL of the `base.js` script. If this :param url: Optional. Provide the URL of the `base.js` script. If this
isn't specified a call will be made to :py:func:`get_basejs_url`. isn't specified a call will be made to :py:func:`get_basejs_url`.
:return: `signatureTimestamp` string :return: ``signatureTimestamp`` string
""" """
if url is None: if url is None:
url = self.get_basejs_url() url = self.get_basejs_url()

View file

@ -93,7 +93,7 @@ class ExploreMixin(MixinProtocol):
Get latest charts data from YouTube Music: Top songs, top videos, top artists and top trending videos. Get latest charts data from YouTube Music: Top songs, top videos, top artists and top trending videos.
Global charts have no Trending section, US charts have an extra Genres section with some Genre charts. Global charts have no Trending section, US charts have an extra Genres section with some Genre charts.
:param country: ISO 3166-1 Alpha-2 country code. Default: ZZ = Global :param country: ISO 3166-1 Alpha-2 country code. Default: ``ZZ`` = Global
:return: Dictionary containing chart songs (only if authenticated with premium account), :return: Dictionary containing chart songs (only if authenticated with premium account),
chart videos, chart artists and trending videos. chart videos, chart artists and trending videos.

View file

@ -15,7 +15,7 @@ class LibraryMixin(MixinProtocol):
""" """
Retrieves the playlists in the user's library. Retrieves the playlists in the user's library.
:param limit: Number of playlists to retrieve. `None` retrieves them all. :param limit: Number of playlists to retrieve. ``None`` retrieves them all.
:return: List of owned playlists. :return: List of owned playlists.
Each item is in the following format:: Each item is in the following format::
@ -55,7 +55,7 @@ class LibraryMixin(MixinProtocol):
:param limit: Number of songs to retrieve :param limit: Number of songs to retrieve
:param validate_responses: Flag indicating if responses from YTM should be validated and retried in case :param validate_responses: Flag indicating if responses from YTM should be validated and retried in case
when some songs are missing. Default: False when some songs are missing. Default: False
:param order: Order of songs to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of songs to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of songs. Same format as :py:func:`get_playlist` :return: List of songs. Same format as :py:func:`get_playlist`
""" """
self._check_auth() self._check_auth()
@ -121,7 +121,7 @@ class LibraryMixin(MixinProtocol):
Gets the albums in the user's library. Gets the albums in the user's library.
:param limit: Number of albums to return :param limit: Number of albums to return
:param order: Order of albums to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of albums to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of albums. :return: List of albums.
Each item is in the following format:: Each item is in the following format::
@ -156,7 +156,7 @@ class LibraryMixin(MixinProtocol):
Gets the artists of the songs in the user's library. Gets the artists of the songs in the user's library.
:param limit: Number of artists to return :param limit: Number of artists to return
:param order: Order of artists to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of artists to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of artists. :return: List of artists.
Each item is in the following format:: Each item is in the following format::
@ -184,7 +184,7 @@ class LibraryMixin(MixinProtocol):
Gets the artists the user has subscribed to. Gets the artists the user has subscribed to.
:param limit: Number of artists to return :param limit: Number of artists to return
:param order: Order of artists to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of artists to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of artists. Same format as :py:func:`get_library_artists` :return: List of artists. Same format as :py:func:`get_library_artists`
""" """
self._check_auth() self._check_auth()
@ -203,7 +203,7 @@ class LibraryMixin(MixinProtocol):
Get podcasts the user has added to the library Get podcasts the user has added to the library
:param limit: Number of podcasts to return :param limit: Number of podcasts to return
:param order: Order of podcasts to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of podcasts to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of podcasts. New Episodes playlist is the first podcast returned, but only if subscribed to relevant podcasts. :return: List of podcasts. New Episodes playlist is the first podcast returned, but only if subscribed to relevant podcasts.
Example:: Example::
@ -249,7 +249,7 @@ class LibraryMixin(MixinProtocol):
Get channels the user has added to the library Get channels the user has added to the library
:param limit: Number of channels to return :param limit: Number of channels to return
:param order: Order of channels to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of channels to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of channels. :return: List of channels.
Example:: Example::
@ -340,9 +340,9 @@ class LibraryMixin(MixinProtocol):
Rates a song ("thumbs up"/"thumbs down" interactions on YouTube Music) Rates a song ("thumbs up"/"thumbs down" interactions on YouTube Music)
:param videoId: Video id :param videoId: Video id
:param rating: One of 'LIKE', 'DISLIKE', 'INDIFFERENT' :param rating: One of ``LIKE``, ``DISLIKE``, ``INDIFFERENT``
| 'INDIFFERENT' removes the previous rating and assigns no rating | ``INDIFFERENT`` removes the previous rating and assigns no rating
:return: Full response :return: Full response
""" """
@ -373,9 +373,9 @@ class LibraryMixin(MixinProtocol):
You can also dislike a playlist/album, which has an effect on your recommendations You can also dislike a playlist/album, which has an effect on your recommendations
:param playlistId: Playlist id :param playlistId: Playlist id
:param rating: One of 'LIKE', 'DISLIKE', 'INDIFFERENT' :param rating: One of ``LIKE``, ``DISLIKE``, ``INDIFFERENT``
| 'INDIFFERENT' removes the playlist/album from the library | ``INDIFFERENT`` removes the playlist/album from the library
:return: Full response :return: Full response
""" """

View file

@ -18,7 +18,7 @@ class PlaylistsMixin(MixinProtocol):
Returns a list of playlist items Returns a list of playlist items
:param playlistId: Playlist id :param playlistId: Playlist id
:param limit: How many songs to return. `None` retrieves them all. Default: 100 :param limit: How many songs to return. ``None`` retrieves them all. Default: 100
:param related: Whether to fetch 10 related playlists or not. Default: False :param related: Whether to fetch 10 related playlists or not. Default: False
:param suggestions_limit: How many suggestions to return. The result is a list of :param suggestions_limit: How many suggestions to return. The result is a list of
suggested playlist items (videos) contained in a "suggestions" key. suggested playlist items (videos) contained in a "suggestions" key.
@ -221,7 +221,7 @@ class PlaylistsMixin(MixinProtocol):
:param title: Playlist title :param title: Playlist title
:param description: Playlist description :param description: Playlist description
:param privacy_status: Playlists can be 'PUBLIC', 'PRIVATE', or 'UNLISTED'. Default: 'PRIVATE' :param privacy_status: Playlists can be ``PUBLIC``, ``PRIVATE``, or ``UNLISTED``. Default: ``PRIVATE``
:param video_ids: IDs of songs to create the playlist with :param video_ids: IDs of songs to create the playlist with
:param source_playlist: Another playlist whose songs should be added to the new playlist :param source_playlist: Another playlist whose songs should be added to the new playlist
:return: ID of the YouTube playlist or full response if there was an error :return: ID of the YouTube playlist or full response if there was an error

View file

@ -99,10 +99,10 @@ class PodcastsMixin(MixinProtocol):
.. note:: .. note::
To add a podcast to your library, you need to call `rate_playlist` on it To add a podcast to your library, you need to call ``rate_playlist`` on it
:param playlistId: Playlist id :param playlistId: Playlist id
:param limit: How many songs to return. `None` retrieves them all. Default: 100 :param limit: How many songs to return. ``None`` retrieves them all. Default: 100
:return: Dict with podcast information :return: Dict with podcast information
Example:: Example::
@ -163,8 +163,8 @@ class PodcastsMixin(MixinProtocol):
.. note:: .. note::
To save an episode, you need to call `add_playlist_items` to add To save an episode, you need to call ``add_playlist_items`` to add
it to the `SE` (saved episodes) playlist. it to the ``SE`` (saved episodes) playlist.
:param videoId: browseId (MPED..) or videoId for a single episode :param videoId: browseId (MPED..) or videoId for a single episode
:return: Dict containing information about the episode :return: Dict containing information about the episode

View file

@ -36,7 +36,7 @@ class SearchMixin(MixinProtocol):
:return: List of results depending on filter. :return: List of results depending on filter.
resultType specifies the type of item (important for default search). resultType specifies the type of item (important for default search).
albums, artists and playlists additionally contain a browseId, corresponding to albums, artists and playlists additionally contain a browseId, corresponding to
albumId, channelId and playlistId (browseId=``VL``+playlistId) albumId, channelId and playlistId (browseId=`VL`+playlistId)
Example list for default search with one result per resultType for brevity. Normally Example list for default search with one result per resultType for brevity. Normally
there are 3 results per resultType and an additional ``thumbnails`` key:: there are 3 results per resultType and an additional ``thumbnails`` key::

View file

@ -27,8 +27,8 @@ class UploadsMixin(MixinProtocol):
""" """
Returns a list of uploaded songs Returns a list of uploaded songs
:param limit: How many songs to return. `None` retrieves them all. Default: 25 :param limit: How many songs to return. ``None`` retrieves them all. Default: 25
:param order: Order of songs to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of songs to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of uploaded songs. :return: List of uploaded songs.
Each item is in the following format:: Each item is in the following format::
@ -74,8 +74,8 @@ class UploadsMixin(MixinProtocol):
""" """
Gets the albums of uploaded songs in the user's library. Gets the albums of uploaded songs in the user's library.
:param limit: Number of albums to return. `None` retrives them all. Default: 25 :param limit: Number of albums to return. ``None`` retrives them all. Default: 25
:param order: Order of albums to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of albums to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of albums as returned by :py:func:`get_library_albums` :return: List of albums as returned by :py:func:`get_library_albums`
""" """
self._check_auth() self._check_auth()
@ -95,8 +95,8 @@ class UploadsMixin(MixinProtocol):
""" """
Gets the artists of uploaded songs in the user's library. Gets the artists of uploaded songs in the user's library.
:param limit: Number of artists to return. `None` retrieves them all. Default: 25 :param limit: Number of artists to return. ``None`` retrieves them all. Default: 25
:param order: Order of artists to return. Allowed values: 'a_to_z', 'z_to_a', 'recently_added'. Default: Default order. :param order: Order of artists to return. Allowed values: ``a_to_z``, ``z_to_a``, ``recently_added``. Default: Default order.
:return: List of artists as returned by :py:func:`get_library_artists` :return: List of artists as returned by :py:func:`get_library_artists`
""" """
self._check_auth() self._check_auth()

View file

@ -20,8 +20,8 @@ class WatchMixin(MixinProtocol):
Get a watch list of tracks. This watch playlist appears when you press Get a watch list of tracks. This watch playlist appears when you press
play on a track in YouTube Music. play on a track in YouTube Music.
Please note that the `INDIFFERENT` likeStatus of tracks returned by this Please note that the ``INDIFFERENT`` likeStatus of tracks returned by this
endpoint may be either `INDIFFERENT` or `DISLIKE`, due to ambiguous data endpoint may be either ``INDIFFERENT`` or ``DISLIKE``, due to ambiguous data
returned by YouTube Music. returned by YouTube Music.
:param videoId: videoId of the played video :param videoId: videoId of the played video