ytubeinsight


Nameytubeinsight JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA Python package for YouTube channel analytics
upload_time2024-09-15 10:42:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT License Copyright (c) 2024 Md. Fahim Bin Amin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords youtube analytics api
VCS
bugtrack_url
requirements google-api-python-client requests beautifulsoup4 pytest pytest-cov flake8 black isort Sphinx sphinx-rtd-theme tox twine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # YTubeInsight

[![PyPI version](https://badge.fury.io/py/ytubeinsight.svg)](https://badge.fury.io/py/ytubeinsight)
[![Python Versions](https://img.shields.io/pypi/pyversions/ytubeinsight.svg)](https://pypi.org/project/ytubeinsight/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Documentation Status](https://readthedocs.org/projects/ytubeinsight/badge/?version=latest)](https://ytubeinsight.readthedocs.io/en/latest/?badge=latest)

YTubeInsight is a Python package for effortless YouTube channel analytics. Track video counts, extract details, and gain insights from YouTube channels with ease.

## Features

- Analyze YouTube channels using either full channel URLs or channel IDs
- Count videos published within the last year
- Retrieve detailed information about each video (title, publish date, URL)
- Easy-to-use API with comprehensive error handling
- Compatibility with Python 3.6+

## Installation

You can install YTubeInsight using pip. We recommend using a virtual environment to manage your dependencies. You can choose between venv (built into Python) or conda based on your preference.

### Option 1: Using venv

1. Create a virtual environment:
   ```
   python -m venv ytubeinsight-env
   ```

2. Activate the virtual environment:
   - On Windows:
     ```
     ytubeinsight-env\Scripts\activate
     ```
   - On macOS and Linux:
     ```
     source ytubeinsight-env/bin/activate
     ```

3. Install YTubeInsight:
   ```
   pip install ytubeinsight
   ```

### Option 2: Using conda

1. Create a conda environment:
   ```
   conda create --name ytubeinsight-env python=3.8
   ```

2. Activate the conda environment:
   ```
   conda activate ytubeinsight-env
   ```

3. Install YTubeInsight:
   ```
   pip install ytubeinsight
   ```

## Quick Start

Here's a simple example of how to use YTubeInsight:

```python
from ytubeinsight import analyze_channel

# Replace with your YouTube Data API key
API_KEY = 'YOUR_API_KEY_HERE'

# Analyze a channel by URL
channel_url = 'https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw'
result = analyze_channel(channel_url, API_KEY)

print(f"Videos published in the last year: {result['video_count']}")

# Print details of the first video
if result['video_data']:
    video = result['video_data'][0]
    print(f"Latest video:")
    print(f"Title: {video['title']}")
    print(f"Published on: {video['published_at']}")
    print(f"URL: {video['url']}")
```

## Detailed Usage

### Analyzing a channel by URL

```python
from ytubeinsight import analyze_channel

result = analyze_channel('https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw', 'YOUR_API_KEY')
```

### Analyzing a channel by ID

```python
from ytubeinsight import analyze_channel

result = analyze_channel('UCJFp8uSYCjXOMnkUyb3CQ3Q', 'YOUR_API_KEY', is_channel_id=True)
```

### Handling errors

```python
from ytubeinsight import analyze_channel, YTubeInsightError

try:
    result = analyze_channel('invalid_channel_url', 'YOUR_API_KEY')
except YTubeInsightError as e:
    print(f"An error occurred: {str(e)}")
```

## API Reference

### analyze_channel(channel_input, api_key, is_channel_id=False)

Analyzes a YouTube channel and returns video data for the past year.

- `channel_input`: Either a full channel URL or channel ID
- `api_key`: YouTube Data API key
- `is_channel_id`: Boolean indicating if channel_input is a channel ID

Returns a dictionary containing:
- `video_count`: Number of videos published in the last year
- `video_data`: List of dictionaries, each containing video details (title, publish date, URL)

For more detailed API documentation, please visit our [Read the Docs page](https://ytubeinsight.readthedocs.io/).

## Obtaining a YouTube Data API Key

To use YTubeInsight, you need a YouTube Data API key. Here's how to get one:

1. Go to the [Google Developers Console](https://console.developers.google.com/).
2. Create a new project or select an existing one.
3. Enable the YouTube Data API v3 for your project.
4. Create credentials (API key) for your project.
5. Use this API key in your YTubeInsight calls.

Remember to keep your API key secret and never share it publicly.

## Requirements

- Python 3.6+
- google-api-python-client
- requests
- beautifulsoup4

## Development

To set up the development environment:

1. Clone the repository:
   ```
   git clone https://github.com/FahimFBA/YTubeInsight.git
   cd YTubeInsight
   ```

2. Create and activate a virtual environment (choose one):
   - Using venv:
     ```
     python -m venv venv
     source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
     ```
   - Using conda:
     ```
     conda create --name ytubeinsight-dev python=3.8
     conda activate ytubeinsight-dev
     ```

3. Install the development dependencies:
   ```
   pip install -e .[dev]
   ```

4. Run the tests:
   ```
   pytest
   ```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

Please make sure to update tests as appropriate and adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Changelog

For a detailed changelog, please see the [CHANGELOG.md](CHANGELOG.md) file.

## Acknowledgments

- Google for providing the YouTube Data API
- All contributors who help improve this package

## Support

If you encounter any problems or have any questions, please [open an issue](https://github.com/FahimFBA/YTubeInsight/issues) on GitHub.

## Disclaimer

This project is not affiliated with, authorized, maintained, sponsored or endorsed by YouTube or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ytubeinsight",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "youtube, analytics, api",
    "author": null,
    "author_email": "\"Md. Fahim Bin Amin\" <fahimbinamin@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/df/b0/e9dbe67fdb8fb079a21bb89b42d752613874fbefe09cc5f720e421ac4d50/ytubeinsight-0.1.2.tar.gz",
    "platform": null,
    "description": "# YTubeInsight\r\n\r\n[![PyPI version](https://badge.fury.io/py/ytubeinsight.svg)](https://badge.fury.io/py/ytubeinsight)\r\n[![Python Versions](https://img.shields.io/pypi/pyversions/ytubeinsight.svg)](https://pypi.org/project/ytubeinsight/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![Documentation Status](https://readthedocs.org/projects/ytubeinsight/badge/?version=latest)](https://ytubeinsight.readthedocs.io/en/latest/?badge=latest)\r\n\r\nYTubeInsight is a Python package for effortless YouTube channel analytics. Track video counts, extract details, and gain insights from YouTube channels with ease.\r\n\r\n## Features\r\n\r\n- Analyze YouTube channels using either full channel URLs or channel IDs\r\n- Count videos published within the last year\r\n- Retrieve detailed information about each video (title, publish date, URL)\r\n- Easy-to-use API with comprehensive error handling\r\n- Compatibility with Python 3.6+\r\n\r\n## Installation\r\n\r\nYou can install YTubeInsight using pip. We recommend using a virtual environment to manage your dependencies. You can choose between venv (built into Python) or conda based on your preference.\r\n\r\n### Option 1: Using venv\r\n\r\n1. Create a virtual environment:\r\n   ```\r\n   python -m venv ytubeinsight-env\r\n   ```\r\n\r\n2. Activate the virtual environment:\r\n   - On Windows:\r\n     ```\r\n     ytubeinsight-env\\Scripts\\activate\r\n     ```\r\n   - On macOS and Linux:\r\n     ```\r\n     source ytubeinsight-env/bin/activate\r\n     ```\r\n\r\n3. Install YTubeInsight:\r\n   ```\r\n   pip install ytubeinsight\r\n   ```\r\n\r\n### Option 2: Using conda\r\n\r\n1. Create a conda environment:\r\n   ```\r\n   conda create --name ytubeinsight-env python=3.8\r\n   ```\r\n\r\n2. Activate the conda environment:\r\n   ```\r\n   conda activate ytubeinsight-env\r\n   ```\r\n\r\n3. Install YTubeInsight:\r\n   ```\r\n   pip install ytubeinsight\r\n   ```\r\n\r\n## Quick Start\r\n\r\nHere's a simple example of how to use YTubeInsight:\r\n\r\n```python\r\nfrom ytubeinsight import analyze_channel\r\n\r\n# Replace with your YouTube Data API key\r\nAPI_KEY = 'YOUR_API_KEY_HERE'\r\n\r\n# Analyze a channel by URL\r\nchannel_url = 'https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw'\r\nresult = analyze_channel(channel_url, API_KEY)\r\n\r\nprint(f\"Videos published in the last year: {result['video_count']}\")\r\n\r\n# Print details of the first video\r\nif result['video_data']:\r\n    video = result['video_data'][0]\r\n    print(f\"Latest video:\")\r\n    print(f\"Title: {video['title']}\")\r\n    print(f\"Published on: {video['published_at']}\")\r\n    print(f\"URL: {video['url']}\")\r\n```\r\n\r\n## Detailed Usage\r\n\r\n### Analyzing a channel by URL\r\n\r\n```python\r\nfrom ytubeinsight import analyze_channel\r\n\r\nresult = analyze_channel('https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw', 'YOUR_API_KEY')\r\n```\r\n\r\n### Analyzing a channel by ID\r\n\r\n```python\r\nfrom ytubeinsight import analyze_channel\r\n\r\nresult = analyze_channel('UCJFp8uSYCjXOMnkUyb3CQ3Q', 'YOUR_API_KEY', is_channel_id=True)\r\n```\r\n\r\n### Handling errors\r\n\r\n```python\r\nfrom ytubeinsight import analyze_channel, YTubeInsightError\r\n\r\ntry:\r\n    result = analyze_channel('invalid_channel_url', 'YOUR_API_KEY')\r\nexcept YTubeInsightError as e:\r\n    print(f\"An error occurred: {str(e)}\")\r\n```\r\n\r\n## API Reference\r\n\r\n### analyze_channel(channel_input, api_key, is_channel_id=False)\r\n\r\nAnalyzes a YouTube channel and returns video data for the past year.\r\n\r\n- `channel_input`: Either a full channel URL or channel ID\r\n- `api_key`: YouTube Data API key\r\n- `is_channel_id`: Boolean indicating if channel_input is a channel ID\r\n\r\nReturns a dictionary containing:\r\n- `video_count`: Number of videos published in the last year\r\n- `video_data`: List of dictionaries, each containing video details (title, publish date, URL)\r\n\r\nFor more detailed API documentation, please visit our [Read the Docs page](https://ytubeinsight.readthedocs.io/).\r\n\r\n## Obtaining a YouTube Data API Key\r\n\r\nTo use YTubeInsight, you need a YouTube Data API key. Here's how to get one:\r\n\r\n1. Go to the [Google Developers Console](https://console.developers.google.com/).\r\n2. Create a new project or select an existing one.\r\n3. Enable the YouTube Data API v3 for your project.\r\n4. Create credentials (API key) for your project.\r\n5. Use this API key in your YTubeInsight calls.\r\n\r\nRemember to keep your API key secret and never share it publicly.\r\n\r\n## Requirements\r\n\r\n- Python 3.6+\r\n- google-api-python-client\r\n- requests\r\n- beautifulsoup4\r\n\r\n## Development\r\n\r\nTo set up the development environment:\r\n\r\n1. Clone the repository:\r\n   ```\r\n   git clone https://github.com/FahimFBA/YTubeInsight.git\r\n   cd YTubeInsight\r\n   ```\r\n\r\n2. Create and activate a virtual environment (choose one):\r\n   - Using venv:\r\n     ```\r\n     python -m venv venv\r\n     source venv/bin/activate  # On Windows, use `venv\\Scripts\\activate`\r\n     ```\r\n   - Using conda:\r\n     ```\r\n     conda create --name ytubeinsight-dev python=3.8\r\n     conda activate ytubeinsight-dev\r\n     ```\r\n\r\n3. Install the development dependencies:\r\n   ```\r\n   pip install -e .[dev]\r\n   ```\r\n\r\n4. Run the tests:\r\n   ```\r\n   pytest\r\n   ```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n1. Fork the repository\r\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\r\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\r\n4. Push to the branch (`git push origin feature/AmazingFeature`)\r\n5. Open a Pull Request\r\n\r\nPlease make sure to update tests as appropriate and adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Changelog\r\n\r\nFor a detailed changelog, please see the [CHANGELOG.md](CHANGELOG.md) file.\r\n\r\n## Acknowledgments\r\n\r\n- Google for providing the YouTube Data API\r\n- All contributors who help improve this package\r\n\r\n## Support\r\n\r\nIf you encounter any problems or have any questions, please [open an issue](https://github.com/FahimFBA/YTubeInsight/issues) on GitHub.\r\n\r\n## Disclaimer\r\n\r\nThis project is not affiliated with, authorized, maintained, sponsored or endorsed by YouTube or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Md. Fahim Bin Amin  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python package for YouTube channel analytics",
    "version": "0.1.2",
    "project_urls": {
        "Bug Reports": "https://github.com/FahimFBA/ytubeinsight/issues",
        "Documentation": "https://ytubeinsight.readthedocs.io/",
        "Homepage": "https://github.com/FahimFBA/ytubeinsight",
        "Source": "https://github.com/FahimFBA/ytubeinsight"
    },
    "split_keywords": [
        "youtube",
        " analytics",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a31fe81fa5feb589fc87291408f76f6cfacdbff7d2c42a3826f112f56911968b",
                "md5": "8a4529052e069acd1814515f28a79016",
                "sha256": "194d6651fb7aab66cc36867cd0bb166f116ca636f8f3d985050ee74a0cc6138f"
            },
            "downloads": -1,
            "filename": "ytubeinsight-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a4529052e069acd1814515f28a79016",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 110330,
            "upload_time": "2024-09-15T10:42:06",
            "upload_time_iso_8601": "2024-09-15T10:42:06.630508Z",
            "url": "https://files.pythonhosted.org/packages/a3/1f/e81fa5feb589fc87291408f76f6cfacdbff7d2c42a3826f112f56911968b/ytubeinsight-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dfb0e9dbe67fdb8fb079a21bb89b42d752613874fbefe09cc5f720e421ac4d50",
                "md5": "69f7bc80a445a8b0ce9afc22ac8f1618",
                "sha256": "8f300d9a132b195ea5831939c8a1483a39f975f37f7bb997bfab0080b4f89748"
            },
            "downloads": -1,
            "filename": "ytubeinsight-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "69f7bc80a445a8b0ce9afc22ac8f1618",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 95949,
            "upload_time": "2024-09-15T10:42:08",
            "upload_time_iso_8601": "2024-09-15T10:42:08.952728Z",
            "url": "https://files.pythonhosted.org/packages/df/b0/e9dbe67fdb8fb079a21bb89b42d752613874fbefe09cc5f720e421ac4d50/ytubeinsight-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-15 10:42:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FahimFBA",
    "github_project": "ytubeinsight",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "google-api-python-client",
            "specs": [
                [
                    "==",
                    "2.86.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "beautifulsoup4",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "7.3.1"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "flake8",
            "specs": [
                [
                    "==",
                    "6.0.0"
                ]
            ]
        },
        {
            "name": "black",
            "specs": [
                [
                    "==",
                    "23.3.0"
                ]
            ]
        },
        {
            "name": "isort",
            "specs": [
                [
                    "==",
                    "5.12.0"
                ]
            ]
        },
        {
            "name": "Sphinx",
            "specs": [
                [
                    "==",
                    "6.2.1"
                ]
            ]
        },
        {
            "name": "sphinx-rtd-theme",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "tox",
            "specs": [
                [
                    "==",
                    "4.5.1"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "4.0.2"
                ]
            ]
        }
    ],
    "lcname": "ytubeinsight"
}
        
Elapsed time: 0.33365s