1- import base64
21import random
3- from datetime import date , datetime , timedelta
2+ from datetime import date , timedelta
43from typing import Literal
54
65import mediacloud .api
109from mcmetadata .exceptions import BadContentError
1110
1211from media_impact_monitor .util .cache import cache , get
13- from media_impact_monitor .util .date import get_latest_data , verify_dates
12+ from media_impact_monitor .util .date import verify_dates
1413from media_impact_monitor .util .env import MEDIACLOUD_API_TOKEN
1514from media_impact_monitor .util .parallel import parallel_tqdm
1615
@@ -62,6 +61,7 @@ def get_mediacloud_counts(
6261def _story_list (** kwargs ):
6362 return search .story_list (** kwargs )
6463
64+
6565def _story_list_all_pages (
6666 query : str ,
6767 start_date : date ,
@@ -98,6 +98,7 @@ def _story_list_all_pages(
9898 all_stories = random .sample (all_stories , sample_size )
9999 return all_stories
100100
101+
101102stories = _story_list_all_pages (
102103 query = "climate change" ,
103104 start_date = date (2024 , 1 , 1 ),
@@ -107,6 +108,7 @@ def _story_list_all_pages(
107108 verbose = True ,
108109)
109110
111+
110112def _slice_date_range (start : date , end : date ) -> list [tuple [date , date ]]:
111113 result = []
112114 current = start .replace (day = 1 )
@@ -232,5 +234,3 @@ def _resolve_country(country: str) -> list[int]:
232234 results = directory .collection_list (name = f"{ country } - state & local" )["results" ]
233235 regional = results [0 ]["id" ]
234236 return [national , regional ]
235-
236- print (_resolve_country ("Germany" ))
0 commit comments