Code Monkey home page Code Monkey logo

sponsorblock.py's Introduction


Logo

sponsorblock.py

A wrapper for the SponsorBlock API
Explore the docs »

View Demo · Report Bug · Request Feature

Contributors Forks Stargazers Issues Code Size MIT License Say Thanke Downloads last Month Downloads last Week Downloads last Day Version Documentation Status Tests Build Code style: black

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

About The Project

sponsorblock.py is a wrapper for the SponsorBlock API

Built With

Getting Started

To install sponsorblock.py:

Prerequisites

You'll need to have python installed in order to use the extension

Installation

  • Installing via pip

    1. Directly installing via pip (Recommended)

      pip install sponsorblock.py
    2. Installing using pip and git

      pip install git+https://github.com/wasi-master/sponsorblock.py.git
  • Cloning then installing

    1. Clone the repo

      git clone https://github.com/wasi-master/sponsorblock.py.git
    2. Changing the current working directory to the directory of the project

      cd sponsorblock.py
    3. Install using pip

      pip install .

Usage

See the documentation

There is also a cli that you can use to get segments from the command line (beta).
To use that run:

sponsorblock video_id

and pass your desired video_id

Roadmap

See the todo list for a list of features yet to be added and features already added. Also see the open issues for issues.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  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

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/wasi-master/sponsorblock.py

Discord: Wasi Master#6969

Email: [email protected]

sponsorblock.py's People

Contributors

heiiow2 avatar svnkoch avatar wasi-master avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sponsorblock.py's Issues

Rate limiting issue?

Hi,
So overall I'm really satisfied with this library, as it does everything I want.
However, I occasionally get this exception and can't figure out why.
HTTPSConnectionPool(host='sponsor.ajay.app', port=443): Max retries exceeded with url: /api/skipSegments?videoID=gxEPV4kolz0&category=sponsor&category=selfpromo&category=interaction&category=intro&category=outro&category=preview&category=music_offtopic&category=poi_highlight&service=YouTube (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001CFA622A310>: Failed to establish a new connection: [WinError 10060] Een verbindingspoging is mislukt omdat de verbonden party niet correct heeft geantwoord na een bepaalde tijd, of de gemaakte verbinding is mislukt omdat de verbonden host niet heeft geantwoord'))
The WinError 10060 says: "An attempt to connect has failed, because the connected party answered incorrectly after a certain time, or the made connection has failed because the connected host hasn't answered'".

Does sponsorblock has a rate limit? If yes, how do I work around it (a sleep() function perhaps) to prevent this?

[BUG]: uncaught connections errors

Description of the bug

Connection errors should be caught and processed, or at least there should be a silent paramater, that says, if an error should be thrown. There is an argument to be made, that this actually shouldn't be the case, but imo the silent parameter should exist.

I also reccomend using logging, then you could just print a warning. When I find the time I am gonna open a pr for this, if you haven't implemented it.

Also sorry if I come of rude, this library really is helpful, but it just crashed my 10 000 lines program. xD
Seriosly keep going.

<33

EDIT: IMO the silent attribute should just return an empty array if anything fails, because yk not segments.

Steps To Reproduce

  1. Use the programm
  2. Pull out your ethernet cable

Additional Information

No response

[BUG]: Error running on versions of Python < 3.8

Description of the bug

When attempting to import this library on Python lower than 3.8, the following error will appear:

ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)

This error was reproduced on 2 of my Raspberry Pis running Raspbian GNU/Linux 10 (buster).
There is fortunately a trivial fix. In utils.py change

from typing import Dict, Literal

to

from typing import Dict
from typing_extensions import Literal

Or put the current Literal import code in a try / except with the exception importing the 2nd way. I could make a pull request but figured this would be easier.

Steps To Reproduce

On Python < 3.8:

pip install sponsorblock
python -c "import sponsorblock"

Additional Information

No response

Usage of Logo + hopefully constructive critique

Hi,

I really appreciate your work, and I already contributed once to your project, but I seem to have overlooked some things. After consideration, I decided it would be less work, to implement my own sponsorblock wrapper than to "fix" the issues in your project.

I got a segment in my readme, why I made this decision. If you want you can read this critique, but ofc you don't have to.

Regardless, I consider using your logo as logo for my wrapper. I can see why you might be opposed to this, thus I ask. Would it be fine with you if I used your logo in my own api wrapper, which kinda does the same? If you are opposed to this I ofc. won't do it.

I hope you have a nice day
<333

Convert segment to JSON string

Hi,
So I want to use get_skip_segments to fetch segments from a YouTube video in JSON format, so JavaScript can use it.
However, the results are apparently Segment objects inside a list wrapper.
Is there a way for me to convert the segment objects into a JSON string, so I can use it for JavaScript?
Because I now get this error: TypeError: Object of type Segment is not JSON serializable

[BUG]: no json header present for adding segments post request

Description of the bug

I wanted to submit segments, however I got a 400 Bad Request. I then modified the client.py Code to show the error by printing response.text in line 391. => "No valid videoID, userID field(s) provided." But these were both valid.
After some searching: You need to send a header that declares you're sending json.

headers = {'Content-type': 'application/json'}
requests.post(url, data=json.dumps(body), headers=headers)

Or alternative you can use the json keyword instead of data

Maybe it would be a good idea to append the request.text to the raised error message so the suer knows what exactly is the problem

Steps To Reproduce

import sponsorblock
client = sponsorblock.Client(user_id="my ID from the settings menu")
client.add_skip_segments(
        "https://www.youtube.com/watch?v=XYZ",
        segment=sponsorblock.Segment(category="intro", start=0, end=6.845000)
    )

=> 400 Bad Request

Additional Information

No response

Can't initialize Client() anymore

After updating to 0.2.0, I can't initialize Sponsorblock Client anymore.

Python 3.9.8 (tags/v3.9.8:bb3fdcf, Nov  5 2021, 20:48:33) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sponsorblock
>>> client = sponsorblock.Client()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...\lib\site-packages\sponsorblock\utils.py", line 124, in __call__
    if cls not in cls._instances:
AttributeError: type object 'Client' has no attribute '_instances'

[FEAT]: Support searchSegments API

Description

The normal getter for segments hides those which are voted negativ etc.
I wanted a method to get all segments of a video, regardless of votes.

This could be achieved by adding a searchSegments Delegation API Method or an actual message which fills in the blanks such you get every segment returned for the given URL.

Additional Information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.