@@ -149,11 +149,19 @@ def get_subtitles(url: str, lang: str) -> str:
149149 return subt_file
150150
151151
152- def get_watched_films ():
152+ def get_watched_films (ask_login : bool = True ):
153153 """Get the list of 'Mijn Films'.
154154
155+ :param ask_login: Whether to show a dialog asking the user to login when
156+ the currently not logged in. If False, an AuthenticationError is raised
157+ without asking the user to sign in.
158+
155159 """
156- history = fetch .fetch_authenticated (fetch .get_json , 'https://api.cinetree.nl/watch-history' , max_age = 10 )
160+ history = fetch .fetch_authenticated (
161+ fetch .get_json ,
162+ url = 'https://api.cinetree.nl/watch-history' ,
163+ ask_login = ask_login ,
164+ max_age = 10 )
157165 sb_films , _ = storyblok .stories_by_uuids (film ['assetId' ] for film in history )
158166 sb_films = {film ['uuid' ]: film for film in sb_films }
159167
@@ -186,13 +194,22 @@ def remove_watched_film(film_uuid):
186194 return resp .status_code == 200
187195
188196
189- def get_favourites (refresh = False ):
190- """Films saved to the personal watch list at Cinetreee."""
197+ def get_favourites (refresh = False , ask_login = True ):
198+ """Films saved to the personal watch list at Cinetreee.
199+
200+ :param refresh: Whether to force requesting data from Cinetree, or just
201+ return already stored data when available.
202+ :param ask_login: Whether to show a dialog asking the user to login when
203+ the currently not logged in. If False, an AuthenticationError is raised
204+ without asking the user to sign in.
205+
206+ """
191207 global favourites
192208 if refresh or favourites is None :
193209 resp = fetch .fetch_authenticated (
194210 fetch .get_json ,
195211 url = 'https://api.cinetree.nl/favorites/' ,
212+ ask_login = ask_login ,
196213 max_age = 0 )
197214
198215 favourites = {item ['uuid' ]: item ['createdAt' ] for item in resp }
0 commit comments