Initial commit
This commit is contained in:
commit
fa53c23557
36
README.md
Normal file
36
README.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
Multiwatcher
|
||||||
|
============
|
||||||
|
|
||||||
|
Found out which services offer a given movie or show title across a matrix of
|
||||||
|
localizations.
|
||||||
|
|
||||||
|
Relies on data from [Justwatch.com](https://www.justwatch.com/).
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
python3 main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Code published under an MIT license.
|
||||||
|
|
||||||
|
```
|
||||||
|
Copyright 2020 Phyks
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
```
|
69
main.py
Normal file
69
main.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
LOCALES = {
|
||||||
|
'fr_FR': 'France',
|
||||||
|
'en_AU': 'Australia',
|
||||||
|
'en_CA': 'Canada',
|
||||||
|
'de_DE': 'Germany',
|
||||||
|
'pl_PL': 'Poland',
|
||||||
|
'en_SG': 'Singapore',
|
||||||
|
'en_UK': 'United Kingdom',
|
||||||
|
}
|
||||||
|
|
||||||
|
query = input('Movie/Show title? ')
|
||||||
|
|
||||||
|
req = requests.get(
|
||||||
|
'https://apis.justwatch.com/content/titles/fr_FR/popular',
|
||||||
|
params={
|
||||||
|
'language': 'fr',
|
||||||
|
'body': '{"page_size":5,"page":1,"query":"%s","content_types":["show","movie"]}' % query
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
list = []
|
||||||
|
|
||||||
|
if not 'items' in req.json() or not req.json()['items']:
|
||||||
|
print('NOT FOUND')
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
for item in req.json()['items']:
|
||||||
|
list.append(item['id'])
|
||||||
|
print('%s. %s' % (i, item['title']))
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
print()
|
||||||
|
title_nb = None
|
||||||
|
while title_nb not in range(len(list)):
|
||||||
|
title_nb = input('Choice? ')
|
||||||
|
try:
|
||||||
|
title_nb = int(title_nb)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
print()
|
||||||
|
|
||||||
|
print('Available from these flatrate services:')
|
||||||
|
for locale, locale_name in LOCALES.items():
|
||||||
|
print('> %s:' % locale_name)
|
||||||
|
req = requests.get(
|
||||||
|
'https://apis.justwatch.com/content/titles/show/%s/locale/%s?language=fr'
|
||||||
|
% (list[title_nb], locale)
|
||||||
|
)
|
||||||
|
offers = {}
|
||||||
|
if not req.json().get('offers', []):
|
||||||
|
print(' None')
|
||||||
|
continue
|
||||||
|
|
||||||
|
for offer in req.json().get('offers', []):
|
||||||
|
if offer['monetization_type'] != 'flatrate':
|
||||||
|
continue
|
||||||
|
offers[offer['urls']['standard_web']] = {}
|
||||||
|
|
||||||
|
for url, offer in offers.items():
|
||||||
|
print(' * %s' % url)
|
||||||
|
print()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
requests
|
Loading…
Reference in New Issue
Block a user