Update docs (closes #7)
This commit is contained in:
parent
83e886b337
commit
fadba30274
8 changed files with 129 additions and 104 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,7 +2,6 @@
|
|||
.vscode
|
||||
headers_auth.json
|
||||
docs/build
|
||||
**.bat
|
||||
**.cfg
|
||||
**.mp3
|
||||
.coverage
|
||||
35
docs/make.bat
Normal file
35
docs/make.bat
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
||||
|
|
@ -13,12 +13,11 @@
|
|||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, '../..')
|
||||
from ytmusicapi import __version__ # noqa: E402
|
||||
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
|
||||
from ytmusicapi import __version__
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'ytmusicapi'
|
||||
|
|
@ -51,7 +50,6 @@ templates_path = ['_templates']
|
|||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
|
|
@ -73,4 +71,4 @@ else:
|
|||
# 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']
|
||||
html_static_path = ['_static']
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
ytmusicapi: Unofficial API for YouTube Music
|
||||
==================================================
|
||||
The purpose of this library is to automate interactions with `YouTube Music <https://music.youtube.com/>`_,
|
||||
such as retrieving your library content or creating large playlists.
|
||||
such as retrieving your library content, managing playlists and uploading songs.
|
||||
To achieve this, it emulates web requests that would occur if you performed the same actions in your web browser.
|
||||
|
||||
**This project is not supported nor endorsed by Google**
|
||||
|
||||
|
|
@ -14,7 +15,9 @@ such as retrieving your library content or creating large playlists.
|
|||
:start-after: features
|
||||
:end-before: end-features
|
||||
|
||||
For a complete documentation of available functions, refer to the :doc:`Reference <reference>`
|
||||
To **get started**, read the :doc:`setup instructions <setup>`.
|
||||
|
||||
For a **complete documentation** of available functions, see the :doc:`Reference <reference>`.
|
||||
|
||||
Contents
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -17,8 +17,13 @@ To do so, follow these steps:
|
|||
- Go to the developer tools (Ctrl-Shift-I) and find an authenticated POST request. You can filter for /browse to easily find a suitable request.
|
||||
- Copy the request headers (right click > copy > copy request headers)
|
||||
|
||||
Now call :py:func:`YTMusic.setup()` and paste the request headers and it will create configuration file
|
||||
in the correct format in the current directory.
|
||||
Now call :py:func:`YTMusic.setup` with the parameter ``filepath=headers_auth.json`` and paste the request headers to the terminal input.
|
||||
If you don't want terminal interaction you can pass the request headers with the ``headers_raw`` parameter.
|
||||
|
||||
The function returns a JSON string with the credentials needed for :doc:`Usage <usage>`. Alternatively, if you passed the filepath parameter as described above,
|
||||
a file called ``headers_auth.json`` will be created in the current directory, which you can pass to ``YTMusic()`` for authentication.
|
||||
|
||||
These credentials remain valid as long as your YTMusic browser session is valid (about 2 years unless you log out).
|
||||
|
||||
Manual file creation
|
||||
--------------------
|
||||
|
|
|
|||
18
setup.py
18
setup.py
|
|
@ -7,9 +7,9 @@ version_line = open(VERSIONFILE).read()
|
|||
version_re = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
||||
match = re.search(version_re, version_line, re.M)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
version = match.group(1)
|
||||
else:
|
||||
raise RuntimeError("Could not find version in '%s'" % VERSIONFILE)
|
||||
raise RuntimeError("Could not find version in '%s'" % VERSIONFILE)
|
||||
|
||||
setup(name='ytmusicapi',
|
||||
version=version,
|
||||
|
|
@ -20,18 +20,10 @@ setup(name='ytmusicapi',
|
|||
author_email='',
|
||||
license='MIT',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'requests >= 2.22'
|
||||
],
|
||||
install_requires=['requests >= 2.22'],
|
||||
extras_require={
|
||||
'dev': [
|
||||
'pre-commit',
|
||||
'flake8',
|
||||
'yapf',
|
||||
'coverage'
|
||||
]
|
||||
'dev': ['pre-commit', 'flake8', 'yapf', 'coverage', 'sphinx', 'sphinx-rtd-theme']
|
||||
},
|
||||
python_requires=">=3.5",
|
||||
include_package_data=True,
|
||||
zip_safe=False
|
||||
)
|
||||
zip_safe=False)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import unittest
|
|||
import configparser
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from ytmusicapi.ytmusic import YTMusic
|
||||
from ytmusicapi.ytmusic import YTMusic # noqa: E402
|
||||
|
||||
config = configparser.RawConfigParser()
|
||||
config.read('./test.cfg', 'utf-8')
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class YTMusic:
|
|||
Otherwise the default account is used. You can retrieve the user ID
|
||||
by going to https://myaccount.google.com and selecting your brand account.
|
||||
The user ID will be in the URL: https://myaccount.google.com/b/user_id/
|
||||
|
||||
"""
|
||||
self.auth = auth
|
||||
|
||||
|
|
@ -85,7 +84,7 @@ class YTMusic:
|
|||
|
||||
:param filepath: Optional filepath to store headers to.
|
||||
:param headers_raw: Optional request headers copied from browser.
|
||||
Otherwise requested from terminal
|
||||
Otherwise requested from terminal
|
||||
:return: configuration headers string
|
||||
"""
|
||||
return setup(filepath, headers_raw)
|
||||
|
|
@ -128,8 +127,6 @@ class YTMusic:
|
|||
"resultType": "song"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
"""
|
||||
body = {'query': query}
|
||||
endpoint = 'search'
|
||||
|
|
@ -202,58 +199,57 @@ class YTMusic:
|
|||
:param channelId: channel id of the artist
|
||||
:return: Dictionary with requested information.
|
||||
|
||||
Example::
|
||||
Example::
|
||||
|
||||
{
|
||||
"name": "Oasis",
|
||||
"description": "Oasis were ...",
|
||||
"views": "1,838,795,605",
|
||||
"songs": {
|
||||
"browseId": "VLPLMpM3Z0118S42R1npOhcjoakLIv1aqnS1",
|
||||
"results": [
|
||||
{
|
||||
"videoId": "ZrOKjDZOtkA",
|
||||
"title": "Wonderwall (Remastered)",
|
||||
"artist": "Oasis",
|
||||
"album": "(What's The Story) Morning Glory? (Remastered)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"albums": {
|
||||
"results": [
|
||||
{
|
||||
"title": "Familiar To Millions",
|
||||
"year": "2018",
|
||||
"browseId": "MPREb_AYetWMZunqA"
|
||||
}
|
||||
],
|
||||
"browseId": "UCmMUZbaYdNH0bEd1PAlAqsA",
|
||||
"params": "6gPTAUNwc0JDbndLYlFBQV..."
|
||||
},
|
||||
"singles": {
|
||||
"results": [
|
||||
{
|
||||
"title": "Stand By Me (Mustique Demo)",
|
||||
"year": "2016",
|
||||
"browseId": "MPREb_7MPKLhibN5G"
|
||||
}
|
||||
],
|
||||
"browseId": "UCmMUZbaYdNH0bEd1PAlAqsA",
|
||||
"params": "6gPTAUNwc0JDbndLYlFBQV..."
|
||||
},
|
||||
"videos": {
|
||||
"results": [
|
||||
{
|
||||
"title": "Wonderwall",
|
||||
"views": "358M",
|
||||
"videoId": "bx1Bh8ZvH84",
|
||||
"playlistId": "PLMpM3Z0118S5xuNckw1HUcj1D021AnMEB"
|
||||
}
|
||||
],
|
||||
"browseId": "VLPLMpM3Z0118S5xuNckw1HUcj1D021AnMEB"
|
||||
}
|
||||
{
|
||||
"name": "Oasis",
|
||||
"description": "Oasis were ...",
|
||||
"views": "1,838,795,605",
|
||||
"songs": {
|
||||
"browseId": "VLPLMpM3Z0118S42R1npOhcjoakLIv1aqnS1",
|
||||
"results": [
|
||||
{
|
||||
"videoId": "ZrOKjDZOtkA",
|
||||
"title": "Wonderwall (Remastered)",
|
||||
"artist": "Oasis",
|
||||
"album": "(What's The Story) Morning Glory? (Remastered)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"albums": {
|
||||
"results": [
|
||||
{
|
||||
"title": "Familiar To Millions",
|
||||
"year": "2018",
|
||||
"browseId": "MPREb_AYetWMZunqA"
|
||||
}
|
||||
],
|
||||
"browseId": "UCmMUZbaYdNH0bEd1PAlAqsA",
|
||||
"params": "6gPTAUNwc0JDbndLYlFBQV..."
|
||||
},
|
||||
"singles": {
|
||||
"results": [
|
||||
{
|
||||
"title": "Stand By Me (Mustique Demo)",
|
||||
"year": "2016",
|
||||
"browseId": "MPREb_7MPKLhibN5G"
|
||||
}
|
||||
],
|
||||
"browseId": "UCmMUZbaYdNH0bEd1PAlAqsA",
|
||||
"params": "6gPTAUNwc0JDbndLYlFBQV..."
|
||||
},
|
||||
"videos": {
|
||||
"results": [
|
||||
{
|
||||
"title": "Wonderwall",
|
||||
"views": "358M",
|
||||
"videoId": "bx1Bh8ZvH84",
|
||||
"playlistId": "PLMpM3Z0118S5xuNckw1HUcj1D021AnMEB"
|
||||
}
|
||||
],
|
||||
"browseId": "VLPLMpM3Z0118S5xuNckw1HUcj1D021AnMEB"
|
||||
}
|
||||
|
||||
}
|
||||
"""
|
||||
body = prepare_browse_endpoint("ARTIST", channelId)
|
||||
endpoint = 'browse'
|
||||
|
|
@ -314,16 +310,15 @@ class YTMusic:
|
|||
:param params: params obtained by :py:func:`get_artist`
|
||||
:return: List of albums or singles
|
||||
|
||||
Example::
|
||||
|
||||
{
|
||||
"browseId": "MPREb_0rtvKhqeCY0",
|
||||
"artist": "Armin van Buuren",
|
||||
"title": "This I Vow (feat. Mila Josef)",
|
||||
"type": "EP",
|
||||
"year": "2020"
|
||||
}
|
||||
Example::
|
||||
|
||||
{
|
||||
"browseId": "MPREb_0rtvKhqeCY0",
|
||||
"artist": "Armin van Buuren",
|
||||
"title": "This I Vow (feat. Mila Josef)",
|
||||
"type": "EP",
|
||||
"year": "2020"
|
||||
}
|
||||
"""
|
||||
body = {"browseId": channelId, "params": params}
|
||||
endpoint = 'browse'
|
||||
|
|
@ -357,7 +352,7 @@ class YTMusic:
|
|||
returned by :py:func:`search`
|
||||
:return: Dictionary with title, description, artist and tracks.
|
||||
|
||||
Each track is in the following format::
|
||||
Each track is in the following format::
|
||||
|
||||
{
|
||||
"title": "Seven",
|
||||
|
|
@ -385,7 +380,7 @@ class YTMusic:
|
|||
"lengthMs": "203406"
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
"""
|
||||
body = prepare_browse_endpoint("ALBUM", browseId)
|
||||
endpoint = 'browse'
|
||||
|
|
@ -440,7 +435,6 @@ class YTMusic:
|
|||
'title': 'Playlist title',
|
||||
'count': 5
|
||||
}
|
||||
|
||||
"""
|
||||
self.__check_auth()
|
||||
body = {'browseId': 'FEmusic_liked_playlists'}
|
||||
|
|
@ -534,7 +528,6 @@ class YTMusic:
|
|||
"artist": "WildVibes",
|
||||
"subscribers": "2.91K"
|
||||
}
|
||||
|
||||
"""
|
||||
self.__check_auth()
|
||||
body = {'browseId': 'FEmusic_library_corpus_track_artists'}
|
||||
|
|
@ -720,7 +713,6 @@ class YTMusic:
|
|||
|
||||
The setVideoId is the unique id of this playlist item and
|
||||
needed for moving/removing playlist items
|
||||
|
||||
"""
|
||||
browseId = "VL" + playlistId if not playlistId.startswith("VL") else playlistId
|
||||
body = prepare_browse_endpoint("PLAYLIST", browseId)
|
||||
|
|
@ -931,7 +923,6 @@ class YTMusic:
|
|||
"title": "A Sky Full Of Stars",
|
||||
"album": "Ghost Stories"
|
||||
}
|
||||
|
||||
"""
|
||||
self.__check_auth()
|
||||
endpoint = 'browse'
|
||||
|
|
@ -957,8 +948,8 @@ class YTMusic:
|
|||
"""
|
||||
Gets the albums of uploaded songs in the user's library.
|
||||
|
||||
:param limit: Number of albums to return
|
||||
:returns List of albums as returned by :py:func:`get_library_albums`
|
||||
:param limit: Number of albums to return. Default: 25
|
||||
:return: List of albums as returned by :py:func:`get_library_albums`
|
||||
"""
|
||||
self.__check_auth()
|
||||
body = {'browseId': 'FEmusic_library_privately_owned_releases'}
|
||||
|
|
@ -987,8 +978,8 @@ class YTMusic:
|
|||
"""
|
||||
Gets the artists of uploaded songs in the user's library.
|
||||
|
||||
:param limit:
|
||||
:returns List of artists as returned by :py:func:`get_library_artists`
|
||||
:param limit: Number of artists to return. Default: 25
|
||||
:return: List of artists as returned by :py:func:`get_library_artists`
|
||||
"""
|
||||
self.__check_auth()
|
||||
body = {'browseId': 'FEmusic_library_privately_owned_artists'}
|
||||
|
|
@ -1013,10 +1004,11 @@ class YTMusic:
|
|||
"""
|
||||
Returns a list of uploaded tracks for the artist.
|
||||
|
||||
:param browseId:
|
||||
:return: List of uploaded songs
|
||||
:param browseId: Browse id of the upload artist, i.e. from :py:func:`get_library_upload_songs`
|
||||
:return: List of uploaded songs.
|
||||
|
||||
Example List::
|
||||
|
||||
Example List:
|
||||
[
|
||||
{
|
||||
"entityId": "t_po_CICr2crg7OWpchDKwoakAQ",
|
||||
|
|
@ -1031,7 +1023,6 @@ class YTMusic:
|
|||
"album": null
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
self.__check_auth()
|
||||
body = prepare_browse_endpoint("ARTIST", browseId)
|
||||
|
|
@ -1047,8 +1038,10 @@ class YTMusic:
|
|||
"""
|
||||
Get information and tracks of an album associated with uploaded tracks
|
||||
|
||||
:param browseId:
|
||||
:returns Dictionary with title, description, artist and tracks.
|
||||
:param browseId: Browse id of the upload album, i.e. from i.e. from :py:func:`get_library_upload_songs`
|
||||
:return: Dictionary with title, description, artist and tracks.
|
||||
|
||||
Example album::
|
||||
|
||||
{
|
||||
"title": "Hard To Stop - Single",
|
||||
|
|
@ -1134,7 +1127,7 @@ class YTMusic:
|
|||
"""
|
||||
Deletes a previously uploaded song or album
|
||||
|
||||
:param entityId: The entity id of the uploaded song to delete,
|
||||
:param entityId: The entity id of the uploaded song or album,
|
||||
e.g. retrieved from :py:func:`get_library_upload_songs`
|
||||
:return: Status String or error
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue