scrazzz / redgifs Goto Github PK
View Code? Open in Web Editor NEWSimple Python API wrapper for the RedGIFs API
Home Page: https://redgifs.rtfd.io
License: MIT License
Simple Python API wrapper for the RedGIFs API
Home Page: https://redgifs.rtfd.io
License: MIT License
examples/download_user.py
not downloading the last page
Download one user with it.
All files are downloaded.
It downloads n - 1 pages
python -m redgifs --version
This line is the problem: while current_page != total_pages:
I'm using something like this.
while True:
...
if current_page <= total_pages:
# Clear the old gifs from the previous page
current_page_gifs.clear()
# Make a new API call to get the gifs from the next page
data = search(search_term, page=current_page)
# Update `current_page_gifs` with the new gifs
current_page_gifs.extend(data.gifs)
else:
break
Enums of Order
: recent
, followers
, top28
does not work.
Code snippet: This fails on all of the above Order enums
from redgifs import API, Order
api = API()
api.login()
api.search("search term", order=Order.recent)
Proper result without errors.
redgifs.errors.HTTPException: 400 (Error: {'code': 'BadRequest', 'message': 'wrong order', 'status': 400})
No response
The search_creators
with a tag result does not contain all creators that have content with that tag and the creators that are returned are missing entries
When using search_creators
with a tag, the result
a) does not contain all creators that have content with that tag. Like if I search on the website for a tag, the creator of almost every result on the website is not in the API result with the same tag.
b) is missing entries, at least for description
and links
, those are not filled like they would be if I query a single creator.
search_creators
, when called with a tag, should return all creators that have content with that tag. Ideally the result contains a count of content of each creator that matches that tag.
Also the fields links
and description
should be filled correctly.
No response
No response
Command line usage with a URL does nothing, no error / nothing saved
The example scripts work but the command line usage of 'redgifs [url]' does nothing, tried several search query URLs.
A query output
Nothing
Window 10 - latest python
No response
data.total
can be bigger than the actual number of gifs
Has only failed me so far with the user and sorting from the script below.
Uncomment one of the Test 1/2/3 lines and run
from redgifs import API, Order
api = API()
api.login()
# Search for the user
USERNAME = 'jenovakitty1'
# Test 1 (Works)
# data = api.search_creator(USERNAME, order=Order.new, count=100)
# Test 2 (Fails)
# Output:
# Downloaded 37 out of 157
# total_gifs: 37
# data.total: 157
# total_pages: 2
data = api.search_creator(USERNAME, order=Order.best, count=100)
# Test 3 (Fails)
# Output: (only 31 gifs this time, this user has 6 images so must be related to that)
# Downloaded 31 out of 157
# total_gifs: 31
# data.total: 157
# total_pages: 2
#data = api.search_creator(USERNAME, order=Order.best, count=80)
total_pages = data.pages
current_page = data.page
# This is the total gifs in the `current_page`
total_gifs = data.gifs
while True:
for i, gifs in enumerate(total_gifs, start=1):
try:
# We do the downloading here.
# Make sure you have a folder called "downloads" in the current directory or else make a new one.
# api.download(gifs.urls.hd, f'downloads/{i}.mp4')
# Print a message to keep track of the downloads
print(f'Downloaded {i} out of {data.total}')
except Exception as e:
raise Exception(f'An error occured while donwloading:\n{e}')
# Update the current page number
current_page += 1
if current_page <= total_pages:
print(f'total_gifs: {str(len(total_gifs))}')
print(f'data.total: {str(data.total)}')
print(f'total_pages: {str(total_pages)}')
# Clear the old gifs from the previous page
total_gifs.clear()
# Make a new API call to get the gifs from the next page
data = api.search_creator(USERNAME, page=current_page)
# Update `total_gifs` with the new gifs
total_gifs.extend(data.gifs)
else:
break
print('Completed!')
All tests detect 37 gifs in one page and finish correctly.
Test 2 and 3 detect 157 instead of 37 total gifs and fail as a result.
No response
Tags.search()
fails on new tags from get_tags()
method.
Make a request with a tag in search()
which isn't available in the Tags
enum.
Proper SearchResult response.
InvalidTag error. Which shouldn't happen because it's a valid tag. The tag was from the RedGifs API and not from the hardcoded tags in the library.
v1.6.0
I'm opening this issue so that I can fix it when I get the time.
i would like to use other tokens than guest to aviod exceeding limits
the redgifs documentation suggests a stringent limit for temporary tokens. https://github.com/Redgifs/api/wiki/Temporary-tokens. using other tokens would solve this
ideally both client and user tokens (probably by login) would be able to be used. but user tokens would be good enough
current solution is to not use this package and implement the auth flow
No response
The count
and page
params for the search() method is broken.
Invoking these won't work
api.search('...', count=1, page=3)
api.search('...', count=1)
api.search('...', page=3)
The final proper SearchResult object
Bad request error with 400 status code
N/A
I'm opening this issue so that I can fix it later when I get the time.
Create an example of how to search using one or more tags
The docs tell me that an instance of Tags can be used for searching.
search_text (str) โ The GIFs to search for. Can be a string or an instance of [Tags]
I tried a few things but I'm unable to create an instance of Tags.
Create an example of how to do this.
No response
No response
Both give an AttributeError
Silly script for testing
from redgifs import API, Order
order = Order.latest
order = Order.oldest
order = Order.best
order = Order.new
order = Order.recent
order = Order.top28
order = Order.trending
I just saw there are test for the orders
Working like the other ones, or being removed from the documentation.
Traceback (most recent call last):
File "/opt/server/bin/redgifs_batch_downloader.py", line 44, in <module>
order = Order.oldest
^^^^^^^^^^^^
File "/usr/lib64/python3.11/enum.py", line 784, in __getattr__
raise AttributeError(name) from None
AttributeError: oldest
> python -m redgifs --version
- Python v3.11.6-final
- redgifs v1.7.2-final
- aiohttp v3.8.6
- system info: Linux 6.5.8-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Oct 20 15:53:48 UTC 2023
BTW the github recomended command (python -m redgifs -v
) for getting this info shows:
redgifs: error: unrecognized arguments: -v
No response
Hello, scrazzz! Video stopped downloading a couple of days ago. Clicking on the download link reports an "HTTP 403 forbidden" error, the website denied the request to display the web page. The problem is on both version 1.2 and 1.3. How can I fix this? :(
When using the cli-tool the downloaded media has no sound
In terminal: redgifs <media_url>
Download the Media as a mp4 with sound
Download the Media as a mp4 without sound
redgifs --version
No response
Are there currently any plans to add upload support to the lib?
Hello! Faced some problems with the random method. The following error appears:
'local variable 'st' referenced before assignment'
api = redgifs.API()
result = api.search(
Tags.random(count=1),
order=Order.best,
count=72,
page=input()
)
The program gives an error when loading a file
Trying to download a file using ID according to instruction. Instead of loading the file, the program gives aTypeerror. It appeared recently, a week ago everything was downloaded correctly.
Does not work even with the example from the repository /examples/download.py. Probably some changes on RedGifs site.
Downloading a file
No response
if i want to download all video from one user i cant,
if i want to do mass download then i have give all videos links.
IF you upload mass downloaded
For Ex: This https://www.redgifs.com/users/XXXX if this user have 400 GIFS
then i want to download all in once. this can make easy.
No response
No response
If you specify a file with a list of redgif URLs, the first URL is downloaded, then the program exits.
redgifs --list <file_with_urls>
Content of each URL in the NL-delimited file to be downloaded in a separate file in the current working directory.
Only 1st file in the list is downloaded, then the program exits with no error.
>python -m redgifs --version
- Python v3.11.6-final
- redgifs v1.8.0-final
- aiohttp v3.9.1
- system info: Windows 10 10.0.22621
Culprit appears to be the premature exit(0)
after the "Download Complete" message is printed in the main "do_dl" function.
If you remove / comment that line, the "--list" functionality works as expected.
A couple days ago, the redgifs API started giving a 401 exception when calling api functions.
import redgifs, os
api = redgifs.API()
url = input() # Full url of redgifs video
result = api.get_gif(url.split('/')[-1])
response = api.download(result.urls.hd, os.path.join(path ,dir, name + ".mp4"))
api.close()
Code executes and video is downloaded.
Traceback (most recent call last):
File "/path/to/file.py", line 26, in
result = api.get_gif(sub.url.split('/')[-1])
File "/path/to/site-packages/redgifs/api.py", line 92, in get_gif
json: Dict[str, Any] = self.http.get_gif(id)['gif']
File "/path/to/site-packages/redgifs/http.py", line 123, in get_gif
return self.request(r, **params)
File "/path/to/site-packages/redgifs/http.py", line 111, in request
raise HTTPException(r, js)
redgifs.errors.HTTPException: 401 (Error: {'code': 'MissingAuthorizationHeader', 'description': 'authorization required to access this service', 'docs': 'https://github.com/Redgifs/api/wiki/API-access'})
The code used to work a couple days ago, but suddenly stopped working.
When trying to open hd/sd links in browser they give: Bad request signature error
Expected: A video/mp4 file
Bad request signature.
No response
When downloading multiple files with API.download(), it seems to pause without an exception, causing the program to halt.
Maybe it's something related to http.get() with default timeout very large.
This issue doesn't seem to happen with same link when retrying the program again, but some other link usually gets stuck. All the links used are generated from api.get_gif(rid).urls.hd
Is there a way to skip a file from downloading when time consumed by it is too high?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.