Add posters + fix movies
This commit is contained in:
parent
fa53c23557
commit
115c237d44
22
main.py
22
main.py
@ -1,10 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.WARNING)
|
||||||
|
|
||||||
LOCALES = {
|
LOCALES = {
|
||||||
'fr_FR': 'France',
|
'fr_FR': 'France',
|
||||||
'en_AU': 'Australia',
|
'en_AU': 'Australia',
|
||||||
@ -24,6 +27,7 @@ req = requests.get(
|
|||||||
'body': '{"page_size":5,"page":1,"query":"%s","content_types":["show","movie"]}' % query
|
'body': '{"page_size":5,"page":1,"query":"%s","content_types":["show","movie"]}' % query
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
logging.info(req.url)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
list = []
|
list = []
|
||||||
@ -33,8 +37,13 @@ if not 'items' in req.json() or not req.json()['items']:
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
for item in req.json()['items']:
|
for item in req.json()['items']:
|
||||||
list.append(item['id'])
|
list.append((item['object_type'], item['id']))
|
||||||
print('%s. %s' % (i, item['title']))
|
print('%s. %s - %s' % (
|
||||||
|
i, item['title'],
|
||||||
|
'https://images.justwatch.com%s' % (
|
||||||
|
item['poster'].replace(r'{profile}', 's276')
|
||||||
|
)
|
||||||
|
))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
print()
|
print()
|
||||||
@ -50,13 +59,16 @@ print()
|
|||||||
print('Available from these flatrate services:')
|
print('Available from these flatrate services:')
|
||||||
for locale, locale_name in LOCALES.items():
|
for locale, locale_name in LOCALES.items():
|
||||||
print('> %s:' % locale_name)
|
print('> %s:' % locale_name)
|
||||||
req = requests.get(
|
url = (
|
||||||
'https://apis.justwatch.com/content/titles/show/%s/locale/%s?language=fr'
|
'https://apis.justwatch.com/content/titles/%s/%s/locale/%s?language=fr'
|
||||||
% (list[title_nb], locale)
|
% (list[title_nb][0], list[title_nb][1], locale)
|
||||||
)
|
)
|
||||||
|
logging.info(url)
|
||||||
|
req = requests.get(url)
|
||||||
offers = {}
|
offers = {}
|
||||||
if not req.json().get('offers', []):
|
if not req.json().get('offers', []):
|
||||||
print(' None')
|
print(' None')
|
||||||
|
print()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for offer in req.json().get('offers', []):
|
for offer in req.json().get('offers', []):
|
||||||
|
Loading…
Reference in New Issue
Block a user