1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added export functionality

This commit is contained in:
krateng 2022-04-04 16:18:18 +02:00
parent 153ab41ce7
commit e0af117805
3 changed files with 19 additions and 0 deletions

View File

@ -121,6 +121,7 @@ def main(*args,**kwargs):
"import":tasks.import_scrobbles, # maloja import /x/y.csv "import":tasks.import_scrobbles, # maloja import /x/y.csv
"backup":tasks.backup, # maloja backup --targetfolder /x/y --include_images "backup":tasks.backup, # maloja backup --targetfolder /x/y --include_images
"generate":tasks.generate, # maloja generate 400 "generate":tasks.generate, # maloja generate 400
"export":tasks.export, # maloja export
# aux # aux
"info":print_info "info":print_info
} }

View File

@ -1,3 +1,4 @@
from .import_scrobbles import import_scrobbles from .import_scrobbles import import_scrobbles
from .backup import backup from .backup import backup
from .generate import generate from .generate import generate
from .export import export # read that line out loud

View File

@ -0,0 +1,17 @@
import json
import os
import time
from doreah.io import col
from ...database.sqldb import get_scrobbles
def export(targetfolder="."):
outputfile = os.path.join(targetfolder,f"maloja_export_{time.strftime('%Y%m%d')}.json")
data = {'scrobbles':get_scrobbles()}
with open(outputfile,'w') as outfd:
json.dump(data,outfd,indent=3)
print(f"Exported {len(data['scrobbles'])} Scrobbles to {col['yellow'](outputfile)}")