Python YouTube
A Python wrapper around for YouTube Data API V3.
.. image:: https://github.com/sns-sdks/python-youtube/workflows/Test/badge.svg
:target: https://github.com/sns-sdks/python-youtube/actions
.. image:: https://img.shields.io/badge/Docs-passing-brightgreen
:target: https://sns-sdks.github.io/python-youtube/
:alt: Documentation Status
.. image:: https://codecov.io/gh/sns-sdks/python-youtube/branch/master/graph/badge.svg
:target: https://codecov.io/gh/sns-sdks/python-youtube
.. image:: https://img.shields.io/pypi/v/python-youtube.svg
:target: https://img.shields.io/pypi/v/python-youtube
======
THANKS
======
Inspired by `Python-Twitter <https://github.com/bear/python-twitter>`_.
Thanks a lot for Python-Twitter Developers.
============
Introduction
============
Library provides an easy way to use YouTube Data API V3.
..
Recently, we are working on the new structure for the library. `Read docs <docs/docs/introduce-new-structure.md>`_ to get more detail.
=============
Documentation
=============
You can view the latest ``python-youtube`` documentation at: https://sns-sdks.github.io/python-youtube/.
Also view the full ``YouTube DATA API`` docs at: https://developers.google.com/youtube/v3/docs/.
==========
Installing
==========
You can install this lib from PyPI:
.. code:: shell
pip install --upgrade python-youtube
# ✨🍰✨
=====
Using
=====
Now, the library covers all resource methods, including ``insert``,``update`` and so on.
Currently, we recommend using ``pyyoutube.Client`` to operate DATA API. It has more features.
Work with Client
----------------
You can just initialize with an api key:
.. code-block:: python
>>> from pyyoutube import Client
>>> client = Client(api_key="your api key")
If you want to get some authorization data. you need to initialize with an access token:
.. code-block:: python
>>> from pyyoutube import Client
>>> client = Client(access_token='your access token')
You can read the docs to see how to get an access token.
Or you can ask for user to do oauth flow:
.. code-block:: python
>>> from pyyoutube import Client
>>> client = Client(client_id="client key", client_secret="client secret")
>>> client.get_authorize_url()
('https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=scope&state=PyYouTube&access_type=offline&prompt=select_account', 'PyYouTube')
>>> client.generate_access_token(authorization_response="link for response")
AccessToken(access_token='token', expires_in=3599, token_type='Bearer')
Now you can use the instance to get data from YouTube.
Get channel detail:
>>> cli.channels.list(channel_id="UC_x5XG1OV2P6uZZ5FSM9Ttw")
ChannelListResponse(kind='youtube#channelListResponse')
>>> cli.channels.list(channel_id="UC_x5XG1OV2P6uZZ5FSM9Ttw", return_json=True)
{'kind': 'youtube#channelListResponse',
'etag': 'eHSYpB_FqHX8vJiGi_sLCu0jkmE',
...
}
To get more usage to see our `client docs <docs/docs/usage/work-with-client.md>`_, or `client examples <examples/clients>`_
Work with API
----------------
..
We still support the old way for the sake of compatibility with older users.
You can just initialize with an api key:
.. code-block:: python
>>> from pyyoutube import Api
>>> api = Api(api_key="your api key")
If you want to get some authorization data. you need to initialize with an access token:
.. code-block:: python
>>> from pyyoutube import Api
>>> api = Api(access_token='your access token')
You can read the docs to see how to get an access token.
Or you can ask for user to do oauth flow:
.. code-block:: python
>>> from pyyoutube import Api
>>> api = Api(client_id="client key", client_secret="client secret")
# Get authorization url
>>> api.get_authorization_url()
('https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=scope&state=PyYouTube&access_type=offline&prompt=select_account', 'PyYouTube')
# user to do
# copy the response url
>>> api.generate_access_token(authorization_response="link for response")
AccessToken(access_token='token', expires_in=3599, token_type='Bearer')
Now you can use the instance to get data from YouTube.
Get channel detail:
.. code-block:: python
>>> channel_by_id = api.get_channel_info(channel_id="UC_x5XG1OV2P6uZZ5FSM9Ttw")
>>> channel_by_id.items
[Channel(kind='youtube#channel', id='UC_x5XG1OV2P6uZZ5FSM9Ttw')]
>>> channel_by_id.items[0].to_dict()
{'kind': 'youtube#channel',
'etag': '"j6xRRd8dTPVVptg711_CSPADRfg/AW8QEqbNRoIJv9KuzCIg0CG6aJA"',
'id': 'UC_x5XG1OV2P6uZZ5FSM9Ttw',
'snippet': {'title': 'Google Developers',
'description': 'The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.',
'customUrl': 'googlecode',
'publishedAt': '2007-08-23T00:34:43.000Z',
'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/a/AGF-l78iFtAxyRZcUBzG91kbKMES19z-zGW5KT20_g=s88-c-k-c0xffffffff-no-rj-mo',
'width': 88,
'height': 88},
'medium': {'url': 'https://yt3.ggpht.com/a/AGF-l78iFtAxyRZcUBzG91kbKMES19z-zGW5KT20_g=s240-c-k-c0xffffffff-no-rj-mo',
'width': 240,
'height': 240},
'high': {'url': 'https://yt3.ggpht.com/a/AGF-l78iFtAxyRZcUBzG91kbKMES19z-zGW5KT20_g=s800-c-k-c0xffffffff-no-rj-mo',
'width': 800,
'height': 800},
'standard': None,
'maxres': None},
'defaultLanguage': None,
'localized': {'title': 'Google Developers',
'description': 'The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.'},
'country': 'US'},
...
}
# Get json response from youtube
>>> api.get_channel_info(channel_id="UC_x5XG1OV2P6uZZ5FSM9Ttw", return_json=True)
{'kind': 'youtube#channelListResponse',
'etag': '17FOkdjp-_FPTiIJXdawBS4jWtc',
...
}
To get more usage to see our `api docs <docs/docs/usage/work-with-api.md>`_, or `api examples <examples/apis>`_
Raw data
{
"_id": null,
"home_page": "https://github.com/sns-sdks/python-youtube",
"name": "python-youtube",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.6",
"maintainer_email": null,
"keywords": "youtube-api, youtube-v3-api, youtube-data-api, youtube-sdk",
"author": "ikaroskun",
"author_email": "merle.liukun@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5f/3c/58013cda4695d90ee3093265f109c46e3943bea7b63151095ce2e11a319d/python_youtube-0.9.7.tar.gz",
"platform": null,
"description": "Python YouTube\n\nA Python wrapper around for YouTube Data API V3.\n\n.. image:: https://github.com/sns-sdks/python-youtube/workflows/Test/badge.svg\n :target: https://github.com/sns-sdks/python-youtube/actions\n\n.. image:: https://img.shields.io/badge/Docs-passing-brightgreen\n :target: https://sns-sdks.github.io/python-youtube/\n :alt: Documentation Status\n\n.. image:: https://codecov.io/gh/sns-sdks/python-youtube/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/sns-sdks/python-youtube\n\n.. image:: https://img.shields.io/pypi/v/python-youtube.svg\n :target: https://img.shields.io/pypi/v/python-youtube\n\n======\nTHANKS\n======\n\nInspired by `Python-Twitter <https://github.com/bear/python-twitter>`_.\n\nThanks a lot for Python-Twitter Developers.\n\n============\nIntroduction\n============\n\nLibrary provides an easy way to use YouTube Data API V3.\n\n.. \n\n Recently, we are working on the new structure for the library. `Read docs <docs/docs/introduce-new-structure.md>`_ to get more detail.\n\n=============\nDocumentation\n=============\n\nYou can view the latest ``python-youtube`` documentation at: https://sns-sdks.github.io/python-youtube/.\n\nAlso view the full ``YouTube DATA API`` docs at: https://developers.google.com/youtube/v3/docs/.\n\n==========\nInstalling\n==========\n\nYou can install this lib from PyPI:\n\n.. code:: shell\n\n pip install --upgrade python-youtube\n # \u2728\ud83c\udf70\u2728\n\n=====\nUsing\n=====\n\nNow, the library covers all resource methods, including ``insert``,``update`` and so on.\n\nCurrently, we recommend using ``pyyoutube.Client`` to operate DATA API. It has more features.\n\nWork with Client\n----------------\n\nYou can just initialize with an api key:\n\n.. code-block:: python\n\n >>> from pyyoutube import Client\n >>> client = Client(api_key=\"your api key\")\n\nIf you want to get some authorization data. you need to initialize with an access token:\n\n.. code-block:: python\n\n >>> from pyyoutube import Client\n >>> client = Client(access_token='your access token')\n\nYou can read the docs to see how to get an access token.\n\nOr you can ask for user to do oauth flow:\n\n.. code-block:: python\n\n >>> from pyyoutube import Client\n >>> client = Client(client_id=\"client key\", client_secret=\"client secret\")\n\n >>> client.get_authorize_url()\n ('https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=scope&state=PyYouTube&access_type=offline&prompt=select_account', 'PyYouTube')\n\n >>> client.generate_access_token(authorization_response=\"link for response\")\n AccessToken(access_token='token', expires_in=3599, token_type='Bearer')\n\nNow you can use the instance to get data from YouTube.\n\nGet channel detail:\n\n >>> cli.channels.list(channel_id=\"UC_x5XG1OV2P6uZZ5FSM9Ttw\")\n ChannelListResponse(kind='youtube#channelListResponse')\n >>> cli.channels.list(channel_id=\"UC_x5XG1OV2P6uZZ5FSM9Ttw\", return_json=True)\n {'kind': 'youtube#channelListResponse',\n 'etag': 'eHSYpB_FqHX8vJiGi_sLCu0jkmE',\n ...\n }\n\nTo get more usage to see our `client docs <docs/docs/usage/work-with-client.md>`_, or `client examples <examples/clients>`_\n\nWork with API\n----------------\n\n..\n\n We still support the old way for the sake of compatibility with older users.\n\nYou can just initialize with an api key:\n\n.. code-block:: python\n\n >>> from pyyoutube import Api\n >>> api = Api(api_key=\"your api key\")\n\nIf you want to get some authorization data. you need to initialize with an access token:\n\n.. code-block:: python\n\n >>> from pyyoutube import Api\n >>> api = Api(access_token='your access token')\n\nYou can read the docs to see how to get an access token.\n\nOr you can ask for user to do oauth flow:\n\n.. code-block:: python\n\n >>> from pyyoutube import Api\n >>> api = Api(client_id=\"client key\", client_secret=\"client secret\")\n # Get authorization url\n >>> api.get_authorization_url()\n ('https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=scope&state=PyYouTube&access_type=offline&prompt=select_account', 'PyYouTube')\n # user to do\n # copy the response url\n >>> api.generate_access_token(authorization_response=\"link for response\")\n AccessToken(access_token='token', expires_in=3599, token_type='Bearer')\n\nNow you can use the instance to get data from YouTube.\n\nGet channel detail:\n\n.. code-block:: python\n\n >>> channel_by_id = api.get_channel_info(channel_id=\"UC_x5XG1OV2P6uZZ5FSM9Ttw\")\n >>> channel_by_id.items\n [Channel(kind='youtube#channel', id='UC_x5XG1OV2P6uZZ5FSM9Ttw')]\n >>> channel_by_id.items[0].to_dict()\n {'kind': 'youtube#channel',\n 'etag': '\"j6xRRd8dTPVVptg711_CSPADRfg/AW8QEqbNRoIJv9KuzCIg0CG6aJA\"',\n 'id': 'UC_x5XG1OV2P6uZZ5FSM9Ttw',\n 'snippet': {'title': 'Google Developers',\n 'description': 'The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.',\n 'customUrl': 'googlecode',\n 'publishedAt': '2007-08-23T00:34:43.000Z',\n 'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/a/AGF-l78iFtAxyRZcUBzG91kbKMES19z-zGW5KT20_g=s88-c-k-c0xffffffff-no-rj-mo',\n 'width': 88,\n 'height': 88},\n 'medium': {'url': 'https://yt3.ggpht.com/a/AGF-l78iFtAxyRZcUBzG91kbKMES19z-zGW5KT20_g=s240-c-k-c0xffffffff-no-rj-mo',\n 'width': 240,\n 'height': 240},\n 'high': {'url': 'https://yt3.ggpht.com/a/AGF-l78iFtAxyRZcUBzG91kbKMES19z-zGW5KT20_g=s800-c-k-c0xffffffff-no-rj-mo',\n 'width': 800,\n 'height': 800},\n 'standard': None,\n 'maxres': None},\n 'defaultLanguage': None,\n 'localized': {'title': 'Google Developers',\n 'description': 'The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.'},\n 'country': 'US'},\n ...\n }\n # Get json response from youtube\n >>> api.get_channel_info(channel_id=\"UC_x5XG1OV2P6uZZ5FSM9Ttw\", return_json=True)\n {'kind': 'youtube#channelListResponse',\n 'etag': '17FOkdjp-_FPTiIJXdawBS4jWtc',\n ...\n }\n\nTo get more usage to see our `api docs <docs/docs/usage/work-with-api.md>`_, or `api examples <examples/apis>`_\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python wrapper around for YouTube Data API.",
"version": "0.9.7",
"project_urls": {
"Homepage": "https://github.com/sns-sdks/python-youtube",
"Repository": "https://github.com/sns-sdks/python-youtube"
},
"split_keywords": [
"youtube-api",
" youtube-v3-api",
" youtube-data-api",
" youtube-sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "243b5d753d187d69cda75061dd3695bae65a68bda44f341e914ea08674eb9288",
"md5": "7121f6733fa6b67a0e3d0c716638b9ce",
"sha256": "00fcf0ff773af829460dba527dfc2eb7ffd0547ddfe24f3dbe8ad3c788c8febb"
},
"downloads": -1,
"filename": "python_youtube-0.9.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7121f6733fa6b67a0e3d0c716638b9ce",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.6",
"size": 82224,
"upload_time": "2024-10-28T09:17:53",
"upload_time_iso_8601": "2024-10-28T09:17:53.426380Z",
"url": "https://files.pythonhosted.org/packages/24/3b/5d753d187d69cda75061dd3695bae65a68bda44f341e914ea08674eb9288/python_youtube-0.9.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5f3c58013cda4695d90ee3093265f109c46e3943bea7b63151095ce2e11a319d",
"md5": "c2c8b8f4b6ff7778a5ff858bf0466831",
"sha256": "bd88611e7e58ad4261d8c9ad0e22253706cafa25edb5784bafe0ccbde2821317"
},
"downloads": -1,
"filename": "python_youtube-0.9.7.tar.gz",
"has_sig": false,
"md5_digest": "c2c8b8f4b6ff7778a5ff858bf0466831",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.6",
"size": 71819,
"upload_time": "2024-10-28T09:17:54",
"upload_time_iso_8601": "2024-10-28T09:17:54.661132Z",
"url": "https://files.pythonhosted.org/packages/5f/3c/58013cda4695d90ee3093265f109c46e3943bea7b63151095ce2e11a319d/python_youtube-0.9.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-28 09:17:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sns-sdks",
"github_project": "python-youtube",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "python-youtube"
}