Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
use rtd theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowrey committed Aug 29, 2023
1 parent 1b078fd commit 1fd79e7
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 81 deletions.
16 changes: 16 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API
===

.. module:: youtube_bz

YouTube API
-----------

.. autoclass:: youtube_bz.api.youtube.Client
:members:

MusicBrainz API
---------------

.. autoclass:: youtube_bz.api.musicbrainz.Client
:members:
14 changes: 7 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys

sys.path.insert(0, os.path.abspath(".."))


# -- Project information -----------------------------------------------------
Expand All @@ -30,7 +31,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = ["sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand All @@ -46,10 +47,9 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "alabaster"
html_theme_options = {"nosidebar": True}
html_theme = "sphinx_rtd_theme"

# 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 = []
83 changes: 16 additions & 67 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,27 @@ YouTubeBrainz
YoutubeBrainz allows you to find and download Youtube videos associated
to an album on MusicBrainz.

Installation
============

Requirements
------------
The User Guide
--------------

Before you use YouTubeBrainz you need to get yourself ``ffmpeg`` installed.
In Debian-like systems you can get it like this:
.. toctree::
:maxdepth: 2

.. code-block:: console
$ sudo apt install ffmpeg
user/install
user/quickstart

API Documentation
-----------------

From PyPi
---------
.. toctree::
:maxdepth: 2

Then you can get YoutubeBrainz from PyPi repository directly:
api

.. code-block:: console
Indices and tables
==================

$ pip install youtube-bz
From source
-----------

You can also install YouTubeBrainz from sources.

First, get a copy of the repository:

.. code-block:: console
$ https://github.com/Flowrey/youtube-bz.git
And then, you can install it with pip:

.. code-block:: console
$ cd youtube-bz
$ pip install -e .
Getting started
===============

To get you started we will fetch an album from a MusicBrainzID.

Find a MBID
-----------

In this exemple we will get the album "Hybrid Theory" from "Linkin Park".

YouTubeBrainz need to use the MIBD of a release to download it.

For instance in the following URL:

.. code-block:: text
https://musicbrainz.org/release/5fc6445c-05ce-34e7-ab31-63bf7d3a9f24
the MBID is ``5fc6445c-05ce-34e7-ab31-63bf7d3a9f24``.

Now that we have the MBID we can download the release thanks to YouTubeBrainz.

Download the Release
--------------------

Downloading the release is really straight forward:

.. code-block:: console
$ youtube-bz download 5fc6445c-05ce-34e7-ab31-63bf7d3a9f24
Your download should start now and you will get the YouTube videos
associated to the MBID album.
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx
sphinx-rtd-theme
11 changes: 11 additions & 0 deletions docs/user/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Installation
============

From PyPi
---------

You can get YoutubeBrainz from PyPi repository directly:

.. code-block:: console
$ pip install youtube-bz
33 changes: 33 additions & 0 deletions docs/user/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Getting started
===============

To get you started we will fetch an album from a MusicBrainzID.

Find a MBID
-----------

In this exemple we will get the album "Hybrid Theory" from "Linkin Park".

YouTubeBrainz need to use the MIBD of a release to download it.

For instance in the following URL:

.. code-block:: text
https://musicbrainz.org/release/5fc6445c-05ce-34e7-ab31-63bf7d3a9f24
the MBID is ``5fc6445c-05ce-34e7-ab31-63bf7d3a9f24``.

Now that we have the MBID we can download the release thanks to YouTubeBrainz.

Download the Release
--------------------

Downloading the release is really straight forward:

.. code-block:: console
$ youtube-bz download 5fc6445c-05ce-34e7-ab31-63bf7d3a9f24
Your download should start now and you will get the YouTube videos
associated to the MBID album.
43 changes: 38 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ isort = "^5.12.0"
pytest = "^7.4.0"
pytest-asyncio = "^0.21.1"
pytest-cov = "^4.1.0"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = "^7.0.1"
sphinx-rtd-theme = "^1.3.0"

[build-system]
requires = ["poetry-core"]
Expand Down
12 changes: 11 additions & 1 deletion youtube_bz/api/musicbrainz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@


class ArtistCredit(TypedDict):
"""A MusicBrainz ArtistCredit."""

name: str


class Track(TypedDict):
"""A MusicBrainz Track."""

title: str
position: int


class Media(TypedDict):
"""A MusicBrainz Media."""

tracks: list[Track]


Expand All @@ -22,11 +28,13 @@ class Media(TypedDict):


class Client:
_host: str
"""MusicBrainz API client."""

_session: ClientSession

@classmethod
async def new(cls, host: str = "https://musicbrainz.org"):
"""Create a new MusicBrainz client."""
self = cls()
self._session = ClientSession(
base_url=host,
Expand All @@ -44,7 +52,9 @@ async def _lookup(self, entity_type: str, mbid: str) -> dict[str, Any]:
return await response.json()

async def lookup_release(self, mbid: str) -> Release:
"""Lookup for a release with it's MBID."""
return cast(Release, await self._lookup("release", mbid))

async def close(self) -> None:
"""Close client session."""
await self._session.close()
5 changes: 4 additions & 1 deletion youtube_bz/api/youtube/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@


class Client:
_host: str
"""YouTube API client."""

_session: ClientSession

@classmethod
async def new(cls, host: str = "https://www.youtube.com"):
"""Create a new YouTube client."""
self = cls()
self._session = ClientSession(base_url=host, raise_for_status=True)

Expand All @@ -26,6 +28,7 @@ async def get_search_results(self, search_query: str) -> str:
return await response.text()

async def close(self) -> None:
"""Close client session."""
await self._session.close()


Expand Down

0 comments on commit 1fd79e7

Please sign in to comment.