This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move gate API clients to their own module. - Add function to download media. - Modify gate API clients to work with IO instead of link to media.
- Loading branch information
1 parent
6f83ad9
commit db8f8b8
Showing
5 changed files
with
66 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from io import BytesIO | ||
from typing import IO | ||
|
||
import requests | ||
|
||
|
||
def download_media(url: str) -> IO[bytes]: | ||
""" | ||
Downloads media by the given link and returns IO with it. | ||
""" | ||
response = requests.get(url, allow_redirects=True) | ||
response.raise_for_status() | ||
reader = BytesIO(response.content) | ||
reader.name = url.split('/')[-1] | ||
return reader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters