ryd-client/README.md

123 lines
3.0 KiB
Markdown
Raw Permalink Normal View History

2021-12-24 09:33:34 +00:00
# RYD Client
Python client library for the **Return YouTube Dislike API**:
- [https://returnyoutubedislike.com/](https://returnyoutubedislike.com/)
- [https://github.com/Anarios/return-youtube-dislike/](https://github.com/Anarios/return-youtube-dislike/)
## Functionality
2021-12-29 13:24:19 +00:00
- Get votes from a single or a list of YouTube video IDs.
2021-12-24 09:33:34 +00:00
- Register your user ID by solving the challenge.
2021-12-29 13:24:19 +00:00
- Cast your vote for a single or a list of YouTube video IDs.
2021-12-24 09:33:34 +00:00
2021-12-24 13:26:47 +00:00
## Install
2021-12-29 13:24:19 +00:00
Download and install the library from [https://pypi.org/project/ryd-client/](https://pypi.org/project/ryd-client/):
2021-12-24 13:26:47 +00:00
```shell
pip install ryd-client
```
2021-12-24 09:33:34 +00:00
## Usage
2021-12-29 13:24:19 +00:00
Take a look at the command examples below.
2021-12-24 09:33:34 +00:00
2021-12-29 12:59:48 +00:00
### Get
Pass a list of YouTube video IDs and get a list of votes or pass a string of a single YouTube video ID to get a single votes dictionary:
2021-12-24 09:33:34 +00:00
```python
2022-01-05 06:33:57 +00:00
from ryd_client import ryd_client
2021-12-24 09:33:34 +00:00
2021-12-29 13:24:19 +00:00
# Examle for a list of IDs
2021-12-29 12:59:48 +00:00
result = ryd_client.get(["kxOuG8jMIgI", "CaaJyRvvaq8"])
2021-12-24 09:33:34 +00:00
[{'id': 'kxOuG8jMIgI',
2021-12-29 12:59:48 +00:00
'likes': 27863,
'dislikes': 509751,
'rating': 1.2113002641063706,
'viewCount': 3211800,
2021-12-24 09:33:34 +00:00
'deleted': False,
'status': 200},
{'id': 'CaaJyRvvaq8',
2021-12-29 12:59:48 +00:00
'likes': 505944,
'dislikes': 13401,
'rating': 4.900014260551845,
'viewCount': 3610078,
2021-12-24 09:33:34 +00:00
'deleted': False,
'status': 200}]
2021-12-29 12:59:48 +00:00
2021-12-29 13:24:19 +00:00
# Example for a single ID
2021-12-29 12:59:48 +00:00
result = ryd_client.get("kxOuG8jMIgI")
{'id': 'kxOuG8jMIgI',
'likes': 27863,
'dislikes': 509751,
'rating': 1.2113002641063706,
'viewCount': 3211800,
'deleted': False,
'status': 200}
2021-12-24 09:33:34 +00:00
```
### Register
To cast a vote, you need to be registered in the API with your user id. Generate a random user id, one per user, store it in your application and reuse for all future votes from this user.
```python
import ryd_client
user_id = ryd_client.generate_user_id()
# Returns a random 36 char string of ascii_letters and digits
'5v3X3mxQOm3fkez8aWsGsEgjpFe0pJNPWIJi'
```
Register your user_id in the api:
```python
2022-01-05 06:33:57 +00:00
from ryd_client import ryd_client
2021-12-24 09:33:34 +00:00
success = ryd_client.register(user_id)
# Returns True on success, False on fail
True
```
2021-12-29 12:59:48 +00:00
### Post
Once your `user_id` is registered, you are allowed to vote. Vote on a list or on a single video ID. Pass a list or a single tuple where the first value of the tuple is the video ID and second value is the vote either as `string` or `int`:
2021-12-24 09:33:34 +00:00
- like: 1
- dislike: -1
- neutral: 0 (aka *undo* your previous vote)
Strings automatically get converted to the matching number, both are valid:
```python
2022-01-05 06:33:57 +00:00
from ryd_client import ryd_client
2021-12-24 09:33:34 +00:00
2021-12-29 13:24:19 +00:00
# Examle for a list of votes
2021-12-24 09:33:34 +00:00
votes = [
("kxOuG8jMIgI", "dislike"),
("CaaJyRvvaq8", 1),
("CEp5SLT-DJg", 0),
]
2021-12-29 12:59:48 +00:00
response = ryd_client.post(votes, user_id=user_id)
2021-12-24 09:33:34 +00:00
[{'id': 'kxOuG8jMIgI', 'status': True, 'vote': -1},
{'id': 'CaaJyRvvaq8', 'status': True, 'vote': 1},
{'id': 'CEp5SLT-DJg', 'status': True, 'vote': 0}]
2021-12-29 13:24:19 +00:00
# Examle for a single vote
2021-12-29 12:59:48 +00:00
vote = ("kxOuG8jMIgI", -1)
response = ryd_client.post(vote, user_id=user_id)
{'id': 'kxOuG8jMIgI', 'status': True, 'vote': -1}
2021-12-24 09:33:34 +00:00
```
## Acknowledgement
2021-12-29 10:41:14 +00:00
If you find this API useful, please consider donating to the [project](https://returnyoutubedislike.com/donate).