Files
predictify/src/runtime.py
T
Dominik ff9d726b47 Feat/import gdrp data (#26)
* Some simple code for extracting data from the jsons

* Jupiter Notebook

* Mac specific gitignore

* Fixed finding paths to floders

* Delete src/gdpr_data directory

* Updated gitignore to include my testing file

* Added the standard saving path for the database in the database handler, this way multiple files dont have to be updated when moving database position

* Moved the API usage wrappers into an own file, added a function for getting multiple track_ids at once, this still needs to be tested more

* Further code for extracting data from the gdpr files

* Forgor

* Final&Tested version of get_multiple_tracks_information endpoint

* Further functionality: The code now extracts the id of each listened song and makes a api call to get info about these songs via the multiple tracks api. Furthermore we track the songs witch the call is made for already and skip these

* Added function to map catalouged ids into the play history

* Added args parser to runtime program, cleaned up some code

* Fixed a bug where the database would always try to create tables, eaven if it exists

* Added some small text for clean interface

* Some final fixes to actual code, fixed db bug, reversed the order of database entries

* Some documentation

* Added -export args to docker runtime

* fix
2025-03-23 18:48:57 +01:00

35 lines
1.3 KiB
Python

import argparse
from time import sleep
from gdpr_export import export_gdpr_data
from scraper import scrape_missing_infos, scraping
# Initialize the parser
parser = argparse.ArgumentParser(description="A python script written in Python3.13 which continuously checks what spotify songs "
"the user is listening to and logging these in a local database. \n"
"The Script also has a export function where it can read out the gdpr data exported by the user.")
# Add optional arguments
parser.add_argument('--verbose', '-v', action='store_true', help="Enable verbose output")
parser.add_argument('--export', '-e', action='store_true', help="Export the gdpr data from spotify if not done already")
# Parse the arguments
args = parser.parse_args()
if args.verbose:
print('Enabled verbose mode')
# implement logger
if args.export:
print('Scraping GDPR Data')
# The next function can gat a int witch defines the amount of songs witch will be scraped from the gdpr files.
# e.g. if 500 is input, the last 500 played songs will come up, if left empty, the last 100.
export_gdpr_data()
scrape_missing_infos()
while True:
print('Scraping API...')
scraping()
print('Done Scraping')
sleep(1800)