Skip to content

Commit

Permalink
fix #703 (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 authored Dec 27, 2024
1 parent 338d63c commit e1ca551
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 102 deletions.
3 changes: 3 additions & 0 deletions docs/source/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wy-nav-content {
max-width: 1080px !important;
}
4 changes: 4 additions & 0 deletions docs/source/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "!layout.html" %}
{% block extrahead %}
<link _statichref="{{ pathto("/style.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}
7 changes: 6 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# -- Project information -----------------------------------------------------

project = "ytmusicapi"
copyright = "2022, sigma67"
copyright = "2024, sigma67"
author = "sigma67"

# The full version, including alpha/beta/rc tags
Expand All @@ -47,6 +47,11 @@
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ My library results are empty even though I set up my cookie correctly.
Please make sure that you don't have multiple Google accounts. ``ytmusicapi`` might be returning
results from a different account which is currently empty. You can set your account using ``X-Goog-AuthUser``
in your headers file (numeric index) or by providing the id of a brand account with ``ytmusic = YTMusic(headers, "1234..")``.
For more details see the :doc:`reference`.
For more details see the :doc:`reference/index`.

Usage
-----------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To achieve this, it emulates web requests that would occur if you performed the

To **get started**, read the :doc:`setup instructions <setup/index>`.

For a **complete documentation** of available functions, see the :doc:`Reference <reference>`.
For a **complete documentation** of available functions, see the :doc:`Reference <reference/index>`.

Contents
--------
Expand All @@ -26,5 +26,5 @@ Contents

setup/index
usage
reference
reference/index
faq
97 changes: 0 additions & 97 deletions docs/source/reference.rst

This file was deleted.

17 changes: 17 additions & 0 deletions docs/source/reference/browsing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Browsing
--------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_home
.. automethod:: YTMusic.get_artist
.. automethod:: YTMusic.get_artist_albums
.. automethod:: YTMusic.get_album
.. automethod:: YTMusic.get_album_browse_id
.. automethod:: YTMusic.get_user
.. automethod:: YTMusic.get_user_playlists
.. automethod:: YTMusic.get_user_videos
.. automethod:: YTMusic.get_song
.. automethod:: YTMusic.get_song_related
.. automethod:: YTMusic.get_lyrics
.. automethod:: YTMusic.get_tasteprofile
.. automethod:: YTMusic.set_tasteprofile
7 changes: 7 additions & 0 deletions docs/source/reference/explore.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Explore
--------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_mood_categories
.. automethod:: YTMusic.get_mood_playlists
.. automethod:: YTMusic.get_charts
18 changes: 18 additions & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Reference
=========

Reference for the YTMusic class.


.. toctree::

ytmusic
setup
search
browsing
explore
watch
library
playlists
podcasts
uploads
22 changes: 22 additions & 0 deletions docs/source/reference/library.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Library
-------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_library_playlists
.. automethod:: YTMusic.get_library_songs
.. automethod:: YTMusic.get_library_albums
.. automethod:: YTMusic.get_library_artists
.. automethod:: YTMusic.get_library_subscriptions
.. automethod:: YTMusic.get_library_podcasts
.. automethod:: YTMusic.get_library_channels
.. automethod:: YTMusic.get_liked_songs
.. automethod:: YTMusic.get_saved_episodes
.. automethod:: YTMusic.get_history
.. automethod:: YTMusic.add_history_item
.. automethod:: YTMusic.remove_history_items
.. automethod:: YTMusic.rate_song
.. automethod:: YTMusic.edit_song_library_status
.. automethod:: YTMusic.rate_playlist
.. automethod:: YTMusic.subscribe_artists
.. automethod:: YTMusic.unsubscribe_artists
.. automethod:: YTMusic.get_account_info
10 changes: 10 additions & 0 deletions docs/source/reference/playlists.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Playlists
---------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_playlist
.. automethod:: YTMusic.create_playlist
.. automethod:: YTMusic.edit_playlist
.. automethod:: YTMusic.delete_playlist
.. automethod:: YTMusic.add_playlist_items
.. automethod:: YTMusic.remove_playlist_items
9 changes: 9 additions & 0 deletions docs/source/reference/podcasts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Podcasts
--------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_channel
.. automethod:: YTMusic.get_channel_episodes
.. automethod:: YTMusic.get_podcast
.. automethod:: YTMusic.get_episode
.. automethod:: YTMusic.get_episodes_playlist
7 changes: 7 additions & 0 deletions docs/source/reference/search.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Search
------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.search
.. automethod:: YTMusic.get_search_suggestions
.. automethod:: YTMusic.remove_search_suggestions
8 changes: 8 additions & 0 deletions docs/source/reference/setup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Setup
-----

See also the :doc:`Setup <../setup/index>` page

.. currentmodule:: ytmusicapi
.. autofunction:: setup
.. autofunction:: setup_oauth
11 changes: 11 additions & 0 deletions docs/source/reference/uploads.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Uploads
-------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_library_upload_songs
.. automethod:: YTMusic.get_library_upload_artists
.. automethod:: YTMusic.get_library_upload_albums
.. automethod:: YTMusic.get_library_upload_artist
.. automethod:: YTMusic.get_library_upload_album
.. automethod:: YTMusic.upload_song
.. automethod:: YTMusic.delete_upload_entity
5 changes: 5 additions & 0 deletions docs/source/reference/watch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Watch
--------

.. currentmodule:: ytmusicapi
.. automethod:: YTMusic.get_watch_playlist
6 changes: 6 additions & 0 deletions docs/source/reference/ytmusic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
YTMusic
-------

.. currentmodule:: ytmusicapi
.. autoclass:: YTMusic
.. automethod:: YTMusic.__init__
12 changes: 11 additions & 1 deletion ytmusicapi/mixins/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,21 @@ def get_history(self) -> list[dict]:
def add_history_item(self, song):
"""
Add an item to the account's history using the playbackTracking URI
obtained from :py:func:`get_song`.
obtained from :py:func:`get_song`. A ``204`` return code indicates success.
Usage::
song = yt_auth.get_song(videoId)
response = yt_auth.add_history_item(song)
.. note::
You need to use the same YTMusic instance as you used for :py:func:`get_song`.
:param song: Dictionary as returned by :py:func:`get_song`
:return: Full response. response.status_code is 204 if successful
"""
self._check_auth()
url = song["playbackTracking"]["videostatsPlaybackUrl"]["baseUrl"]
CPNA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
cpn = "".join(CPNA[randint(0, 256) & 63] for _ in range(0, 16))
Expand Down

0 comments on commit e1ca551

Please sign in to comment.