2022-10-14 14:55:23 +00:00
|
|
|
import metadata
|
2022-10-17 12:56:32 +00:00
|
|
|
import download_links
|
2022-10-17 22:27:30 +00:00
|
|
|
import url_to_path
|
2022-10-17 17:28:33 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
TEMP = "temp"
|
|
|
|
STEP_ONE_CACHE = ".cache1.csv"
|
|
|
|
STEP_TWO_CACHE = ".cache2.csv"
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
2022-10-14 14:55:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def search_for_metadata(query: str):
|
2022-10-17 17:28:33 +00:00
|
|
|
search = metadata.Search(query=query, temp=TEMP)
|
2022-10-14 14:55:23 +00:00
|
|
|
|
|
|
|
print(search.options)
|
|
|
|
while True:
|
2022-10-17 17:28:33 +00:00
|
|
|
input_ = input(
|
|
|
|
"q to quit, ok to download, .. for previous options, . for current options, int for this element: ").lower()
|
2022-10-14 14:55:23 +00:00
|
|
|
input_.strip()
|
|
|
|
if input_ == "q":
|
|
|
|
exit(0)
|
|
|
|
if input_ == "ok":
|
|
|
|
return search
|
|
|
|
if input_ == ".":
|
|
|
|
print(search.options)
|
|
|
|
continue
|
|
|
|
if input_ == "..":
|
|
|
|
print(search.get_previous_options())
|
|
|
|
continue
|
|
|
|
if input_.isdigit():
|
|
|
|
print(search.choose(int(input_)))
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
def cli():
|
|
|
|
search = search_for_metadata(query=input("initial query: "))
|
2022-10-17 17:28:33 +00:00
|
|
|
logging.info("Starting Downloading of metadata")
|
|
|
|
search.download(file=STEP_ONE_CACHE)
|
2022-10-14 14:55:23 +00:00
|
|
|
|
2022-10-17 17:28:33 +00:00
|
|
|
logging.info("Fetching Download Links")
|
2022-10-17 22:27:30 +00:00
|
|
|
download_links.Download(file=STEP_TWO_CACHE, metadata_csv=STEP_ONE_CACHE, temp=TEMP)
|
|
|
|
|
|
|
|
logging.info("creating Paths")
|
|
|
|
url_to_path.UrlPath("dsbm")
|
2022-10-17 12:56:32 +00:00
|
|
|
|
2022-10-14 14:55:23 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
cli()
|