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:
parent
153ab41ce7
commit
e0af117805
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
17
maloja/proccontrol/tasks/export.py
Normal file
17
maloja/proccontrol/tasks/export.py
Normal 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)}")
|
Loading…
Reference in New Issue
Block a user