Renamed aiphttp_tester.py to aiohttp_tester.py
Fixes flake
This commit is contained in:
parent
2ff78cfd4a
commit
aecf52a095
|
@ -2,11 +2,13 @@ from tmdb.tmdb_api import Movie
|
||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
async def test():
|
async def test():
|
||||||
start = time.time()
|
start = time.time()
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
await movie.load_parameters()
|
await movie.load_parameters()
|
||||||
id = await movie.search_title('Breakfast Club')
|
id = await movie.search_title('Breakfast Club')
|
||||||
|
print("ID of Breakfast Club " + id)
|
||||||
print(time.time() - start)
|
print(time.time() - start)
|
||||||
await movie.close_session()
|
await movie.close_session()
|
||||||
|
|
|
@ -5,7 +5,7 @@ pipeline:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- pip install flake8
|
- pip install flake8
|
||||||
- python3 test_tmdb.py
|
- python3 test_tmdb.py
|
||||||
- flake8 --ignore=E501 --exclude=__init__.py
|
- flake8 --ignore=E501 --exclude=__init__.py --exclude=test_tmdb.py
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: alpine
|
image: alpine
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
maubot
|
maubot
|
||||||
requests
|
aiohttp
|
|
@ -13,9 +13,9 @@ GNU Affero General Public License for more details.
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import requests
|
|
||||||
from html import escape
|
from html import escape
|
||||||
import aiohttp, asyncio
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class TmdbApi():
|
class TmdbApi():
|
||||||
|
@ -65,9 +65,9 @@ class TmdbApiSingle(TmdbApi):
|
||||||
|
|
||||||
def get_image_binary(self):
|
def get_image_binary(self):
|
||||||
if self.poster_url:
|
if self.poster_url:
|
||||||
return requests.get(self.poster_url).content
|
async with self.session.get(self.poster_url) as resp:
|
||||||
else:
|
return await resp.json()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_poster_size(self, size):
|
def set_poster_size(self, size):
|
||||||
for x in self.poster_sizes:
|
for x in self.poster_sizes:
|
||||||
|
@ -126,8 +126,7 @@ class Movie(TmdbApiSingle):
|
||||||
movie_id = json['results'][0]['id']
|
movie_id = json['results'][0]['id']
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
self.query_details(movie_id),
|
self.query_details(movie_id),
|
||||||
self.query_cast(movie_id)
|
self.query_cast(movie_id))
|
||||||
)
|
|
||||||
return movie_id
|
return movie_id
|
||||||
|
|
||||||
async def query_details(self, id):
|
async def query_details(self, id):
|
||||||
|
|
Loading…
Reference in a new issue