Compare commits
2 Commits
41860df682
...
00b3f49063
Author | SHA1 | Date |
---|---|---|
Sarah | 00b3f49063 | |
Sarah | 72c4e5864e |
|
@ -0,0 +1,40 @@
|
|||
import argparse
|
||||
from datetime import datetime
|
||||
import json
|
||||
from progress.bar import IncrementalBar
|
||||
|
||||
from vcinema_utils import VCinemaUtils
|
||||
|
||||
|
||||
def get_new_years(token_id, token_secret, year):
|
||||
print("Getting viewings")
|
||||
viewings = VCinemaUtils.get_vcinema_viewings(token_id, token_secret)
|
||||
|
||||
with IncrementalBar('Retrieving movie data', max=len(viewings), suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
|
||||
VCinemaUtils.add_imdb_data_to_viewings(viewings, ["countries"], bar)
|
||||
|
||||
viewings_before_year = VCinemaUtils.get_viewings_before_date(viewings, datetime(day=31, month=12, year=year-1))
|
||||
viewings_end_of_year = VCinemaUtils.get_viewings_before_date(viewings, datetime(day=31, month=12, year=year))
|
||||
|
||||
viewings_before_year_filtered_by_year = VCinemaUtils.filter_viewings(viewings_before_year, "countries")
|
||||
viewings_end_of_year_filtered_by_year = VCinemaUtils.filter_viewings(viewings_end_of_year, "countries")
|
||||
|
||||
years_before = set(list(viewings_before_year_filtered_by_year.keys()))
|
||||
years_after = set(list(viewings_end_of_year_filtered_by_year.keys()))
|
||||
|
||||
years_diff = years_after - years_before
|
||||
|
||||
print(years_diff)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Update wiki pages.')
|
||||
|
||||
parser.add_argument('year', type=int)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open('../token.json') as json_file:
|
||||
token = json.load(json_file)
|
||||
|
||||
get_new_years(token['token_id'], token['token_secret'], args.year)
|
|
@ -0,0 +1,40 @@
|
|||
import argparse
|
||||
from datetime import datetime
|
||||
import json
|
||||
from progress.bar import IncrementalBar
|
||||
|
||||
from vcinema_utils import VCinemaUtils
|
||||
|
||||
|
||||
def get_new_years(token_id, token_secret, year):
|
||||
print("Getting viewings")
|
||||
viewings = VCinemaUtils.get_vcinema_viewings(token_id, token_secret)
|
||||
|
||||
with IncrementalBar('Retrieving movie data', max=len(viewings), suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
|
||||
VCinemaUtils.add_imdb_data_to_viewings(viewings, ["year"], bar)
|
||||
|
||||
viewings_before_year = VCinemaUtils.get_viewings_before_date(viewings, datetime(day=31, month=12, year=year-1))
|
||||
viewings_end_of_year = VCinemaUtils.get_viewings_before_date(viewings, datetime(day=31, month=12, year=year))
|
||||
|
||||
viewings_before_year_filtered_by_year = VCinemaUtils.filter_viewings(viewings_before_year, "year")
|
||||
viewings_end_of_year_filtered_by_year = VCinemaUtils.filter_viewings(viewings_end_of_year, "year")
|
||||
|
||||
years_before = set(list(viewings_before_year_filtered_by_year.keys()))
|
||||
years_after = set(list(viewings_end_of_year_filtered_by_year.keys()))
|
||||
|
||||
years_diff = years_after - years_before
|
||||
|
||||
print(years_diff)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Update wiki pages.')
|
||||
|
||||
parser.add_argument('year', type=int)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open('../token.json') as json_file:
|
||||
token = json.load(json_file)
|
||||
|
||||
get_new_years(token['token_id'], token['token_secret'], args.year)
|
|
@ -1,6 +1,7 @@
|
|||
from collections import Counter
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import csv
|
||||
from datetime import datetime
|
||||
|
||||
from imdb_utils import IMDbUtils
|
||||
from bookstack import Bookstack
|
||||
|
@ -33,7 +34,9 @@ def get_vcinema_viewings(token_id, token_secret, viewings_csv=None, combine_repe
|
|||
if combine_repeat_viewings:
|
||||
for viewing in viewings:
|
||||
viewing['viewings'] = [
|
||||
{'date_watched': viewing['date_watched'], 'season': viewing['season'], 'rating': viewing['rating']}]
|
||||
{'date_watched': datetime.strptime(viewing['date_watched'], "%Y-%m-%d"),
|
||||
'season': viewing['season'],
|
||||
'rating': viewing['rating']}]
|
||||
viewing.pop('date_watched')
|
||||
viewing.pop('season')
|
||||
viewing.pop('rating')
|
||||
|
@ -117,6 +120,16 @@ def filter_viewings(viewings, filter_field):
|
|||
return viewings_filtered
|
||||
|
||||
|
||||
def get_viewings_before_date(viewings, date):
|
||||
viewings_before_date = []
|
||||
|
||||
for viewing in viewings:
|
||||
if all(view_date["date_watched"] < date for view_date in viewing["viewings"]):
|
||||
viewings_before_date.append(viewing)
|
||||
|
||||
return viewings_before_date
|
||||
|
||||
|
||||
def get_film_list(films):
|
||||
film_links = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue