initial commit
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import json
|
||||
import logging as logger
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import file_renamer
|
||||
|
||||
logger.basicConfig(
|
||||
format=f"%(asctime)s {logger.BASIC_FORMAT}",
|
||||
level=logger.DEBUG,
|
||||
handlers=[
|
||||
logger.FileHandler(Path(__file__).with_name("jd2_hook.log"), mode="a"),
|
||||
logger.StreamHandler(),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
payload = json.loads(sys.argv[1])
|
||||
except (IndexError, ValueError):
|
||||
logger.error("Expected JSON as first argument")
|
||||
return 1
|
||||
|
||||
for link in payload["links"]:
|
||||
path = link["download_path"]
|
||||
f = Path(path)
|
||||
logger.info("")
|
||||
if f.is_file():
|
||||
file_renamer.fix_dates([f])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.debug(f"Got called with: {sys.argv}")
|
||||
exit(main())
|
||||
Reference in New Issue
Block a user