update with single and list example
This commit is contained in:
parent
3d65fb8eba
commit
18dbb950f3
57
README.md
57
README.md
|
@ -20,29 +20,45 @@ pip install ryd-client
|
|||
## Usage
|
||||
Some command example
|
||||
|
||||
### Get Votes
|
||||
Pass a list of YouTube video IDs and get a list of votes.
|
||||
### 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:
|
||||
|
||||
```python
|
||||
import ryd_client
|
||||
|
||||
ratings = ryd_client.get_votes(["kxOuG8jMIgI", "CaaJyRvvaq8"])
|
||||
# Passing a list returns a list of dictionaries
|
||||
# with ratings for every video ID returns a list
|
||||
|
||||
result = ryd_client.get(["kxOuG8jMIgI", "CaaJyRvvaq8"])
|
||||
|
||||
# Returns a list of dictionaries with ratings for every video ID
|
||||
[{'id': 'kxOuG8jMIgI',
|
||||
'likes': 27569,
|
||||
'dislikes': 503144,
|
||||
'rating': 1.2117898772151874,
|
||||
'viewCount': 3177346,
|
||||
'likes': 27863,
|
||||
'dislikes': 509751,
|
||||
'rating': 1.2113002641063706,
|
||||
'viewCount': 3211800,
|
||||
'deleted': False,
|
||||
'status': 200},
|
||||
{'id': 'CaaJyRvvaq8',
|
||||
'likes': 502489,
|
||||
'dislikes': 13270,
|
||||
'rating': 4.900305046067389,
|
||||
'viewCount': 3575816,
|
||||
'likes': 505944,
|
||||
'dislikes': 13401,
|
||||
'rating': 4.900014260551845,
|
||||
'viewCount': 3610078,
|
||||
'deleted': False,
|
||||
'status': 200}]
|
||||
|
||||
|
||||
# passing a single ID returns a dictionary
|
||||
# with ratings from a single video
|
||||
|
||||
result = ryd_client.get("kxOuG8jMIgI")
|
||||
|
||||
{'id': 'kxOuG8jMIgI',
|
||||
'likes': 27863,
|
||||
'dislikes': 509751,
|
||||
'rating': 1.2113002641063706,
|
||||
'viewCount': 3211800,
|
||||
'deleted': False,
|
||||
'status': 200}
|
||||
```
|
||||
|
||||
### Register
|
||||
|
@ -70,8 +86,8 @@ True
|
|||
|
||||
```
|
||||
|
||||
### Post Votes
|
||||
Once your `user_id` is registered, you are allowed to vote. Vote on a list of video IDs. Pass a list of tuples where the first value is the video ID and second value is the vote either as `string` or `int`:
|
||||
### 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`:
|
||||
- like: 1
|
||||
- dislike: -1
|
||||
- neutral: 0 (aka *undo* your previous vote)
|
||||
|
@ -81,19 +97,28 @@ Strings automatically get converted to the matching number, both are valid:
|
|||
```python
|
||||
import ryd_client
|
||||
|
||||
# voting on a list of videos
|
||||
# returns a list of results
|
||||
votes = [
|
||||
("kxOuG8jMIgI", "dislike"),
|
||||
("CaaJyRvvaq8", 1),
|
||||
("CEp5SLT-DJg", 0),
|
||||
]
|
||||
|
||||
response = ryd_client.post_votes(votes, user_id=user_id)
|
||||
response = ryd_client.post(votes, user_id=user_id)
|
||||
|
||||
# Returns a list of dictionaries for every vote cast
|
||||
[{'id': 'kxOuG8jMIgI', 'status': True, 'vote': -1},
|
||||
{'id': 'CaaJyRvvaq8', 'status': True, 'vote': 1},
|
||||
{'id': 'CEp5SLT-DJg', 'status': True, 'vote': 0}]
|
||||
|
||||
# voting on a single video
|
||||
# returns a single result
|
||||
|
||||
vote = ("kxOuG8jMIgI", -1)
|
||||
response = ryd_client.post(vote, user_id=user_id)
|
||||
|
||||
{'id': 'kxOuG8jMIgI', 'status': True, 'vote': -1}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue