@@ -83,17 +83,17 @@ def print_list(snapshots):
8383
8484
8585# create filelist
86- def query_list (snapshots : sc .SnapshotCollection , url : str , range : int , mode : str ):
86+ def query_list (snapshots : sc .SnapshotCollection , url : str , range : int , explicit : bool , mode : str ):
8787 try :
8888 v .write ("\n Querying snapshots..." )
8989 if range :
9090 range = datetime .now ().year - range
9191 range = "&from=" + str (range )
9292 else :
9393 range = ""
94- cdxQuery = f"https://web.archive.org/cdx/search/xd?output=json&url=*.{ url } /*{ range } &fl=timestamp,original&filter=!statuscode:200"
94+ cdx_url = f"*.{ url } /*" if not explicit else f"{ url } "
95+ cdxQuery = f"https://web.archive.org/cdx/search/xd?output=json&url={ cdx_url } { range } &fl=timestamp,original&filter=!statuscode:200"
9596 cdxResult = requests .get (cdxQuery )
96- if cdxResult .status_code != 200 : v .write (f"\n -----> ERROR: could not query snapshots, status code: { cdxResult .status_code } " ); exit ()
9797 snapshots .create_full (cdxResult )
9898 if mode == "current" : snapshots .create_current ()
9999 v .write (f"\n -----> { snapshots .count_list ()} snapshots found" )
@@ -142,6 +142,9 @@ def download_list(snapshots, output, retry, worker):
142142 """
143143 Download a list of urls in format: [{"timestamp": "20190815104545", "url": "https://www.google.com/"}]
144144 """
145+ if snapshots .count_list () == 0 :
146+ v .write ("\n No snapshots found to download" )
147+ return
145148 v .write ("\n Downloading latest snapshots of each file..." , progress = 0 )
146149 download_list = snapshots .CDX_LIST
147150 if worker > 1 :
0 commit comments