Renamed aiphttp_tester.py to aiohttp_tester.py

Fixes flake
This commit is contained in:
lomion 2021-09-22 09:54:27 +02:00
parent 2ff78cfd4a
commit aecf52a095
4 changed files with 11 additions and 10 deletions

View file

@ -2,12 +2,14 @@ from tmdb.tmdb_api import Movie
import asyncio
import time
async def test():
start = time.time()
movie = Movie()
await movie.load_parameters()
id = await movie.search_title('Breakfast Club')
print("ID of Breakfast Club " + id)
print(time.time() - start)
await movie.close_session()
asyncio.run(test())

View file

@ -5,7 +5,7 @@ pipeline:
- pip install -r requirements.txt
- pip install flake8
- python3 test_tmdb.py
- flake8 --ignore=E501 --exclude=__init__.py
- flake8 --ignore=E501 --exclude=__init__.py --exclude=test_tmdb.py
build:
image: alpine

View file

@ -1,2 +1,2 @@
maubot
requests
aiohttp

View file

@ -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
along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
'''
import requests
from html import escape
import aiohttp, asyncio
import aiohttp
import asyncio
class TmdbApi():
@ -65,9 +65,9 @@ class TmdbApiSingle(TmdbApi):
def get_image_binary(self):
if self.poster_url:
return requests.get(self.poster_url).content
else:
return None
async with self.session.get(self.poster_url) as resp:
return await resp.json()
return None
def set_poster_size(self, size):
for x in self.poster_sizes:
@ -126,8 +126,7 @@ class Movie(TmdbApiSingle):
movie_id = json['results'][0]['id']
await asyncio.gather(
self.query_details(movie_id),
self.query_cast(movie_id)
)
self.query_cast(movie_id))
return movie_id
async def query_details(self, id):