20250407.1744046757
This commit is contained in:
parent
cfec3861e2
commit
582a9f1380
3 changed files with 44 additions and 15 deletions
|
@ -27,8 +27,8 @@ set backspace=indent,eol,start " backspace removes all (indents, EO
|
||||||
|
|
||||||
set scrolloff=10 " let 10 lines before/after cursor during scroll
|
set scrolloff=10 " let 10 lines before/after cursor during scroll
|
||||||
|
|
||||||
" set clipboard=unnamed " use system clipboard
|
set clipboard=unnamed " use system clipboard
|
||||||
set clipboard=unnamedplus
|
" set clipboard=unnamedplus
|
||||||
|
|
||||||
set exrc " enable usage of additional .vimrc files from working directory
|
set exrc " enable usage of additional .vimrc files from working directory
|
||||||
set secure " prohibit .vimrc files to execute shell, create files, etc...
|
set secure " prohibit .vimrc files to execute shell, create files, etc...
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
# import cProfile
|
# import cProfile
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# import pstats
|
# import pstats
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
@ -106,9 +108,9 @@ def convert_diary_date(date_str):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def download_file(url, filename, diary_path, headers):
|
def download_file(url, filename, diary_path, headers, metadata_id):
|
||||||
ext = os.path.splitext(url)[-1]
|
ext = os.path.splitext(url)[-1]
|
||||||
filename = f"{int(time.time())}_{filename}"
|
filename = f"id{metadata_id}_{int(time.time())}_{filename}"
|
||||||
if not Path(diary_path / FILES_PATH).exists():
|
if not Path(diary_path / FILES_PATH).exists():
|
||||||
Path(diary_path / FILES_PATH).mkdir(parents=True, exist_ok=True)
|
Path(diary_path / FILES_PATH).mkdir(parents=True, exist_ok=True)
|
||||||
filepath = Path(diary_path / FILES_PATH / filename)
|
filepath = Path(diary_path / FILES_PATH / filename)
|
||||||
|
@ -312,8 +314,10 @@ def fetch_geo(metadata_id: int, create_time_timestamp: int, conn: sqlite3.Connec
|
||||||
geo_url,
|
geo_url,
|
||||||
geo_headers,
|
geo_headers,
|
||||||
data={
|
data={
|
||||||
"from": "1970-01-01",
|
"from": datetime.fromtimestamp(int(time.time()) - 2592000).strftime(
|
||||||
"limit": 20,
|
"%Y-%m-%d"
|
||||||
|
), # 30 days
|
||||||
|
# "limit": 1000,
|
||||||
"device": Config.geo_device,
|
"device": Config.geo_device,
|
||||||
"user": Config.geo_user,
|
"user": Config.geo_user,
|
||||||
},
|
},
|
||||||
|
@ -418,6 +422,25 @@ def doctor():
|
||||||
print(e)
|
print(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def remove_attachment(metadata_id):
|
||||||
|
"""Remove file from attachments directory by 'metadata_id' - 'id12_1741177528_IMG_6141.jpeg'"""
|
||||||
|
files = list(Path(diary_path / FILES_PATH).glob(f"id{metadata_id}_*"))
|
||||||
|
if len(files) < 1:
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(files) > 1:
|
||||||
|
if (
|
||||||
|
input(f"There are {len(files)} files. Remove them all? (Y/N): ")
|
||||||
|
.strip()
|
||||||
|
.upper()
|
||||||
|
!= "Y"
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
print("There are mistaken attachment, I will delete it!")
|
||||||
|
for file in files:
|
||||||
|
file.unlink(missing_ok=True)
|
||||||
|
|
||||||
def process_metadata(m):
|
def process_metadata(m):
|
||||||
conn = db_connection(diary_path)
|
conn = db_connection(diary_path)
|
||||||
diary_datetime, result = check_jrnl(metadata=m)
|
diary_datetime, result = check_jrnl(metadata=m)
|
||||||
|
@ -432,6 +455,7 @@ def doctor():
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
remove_metadata(conn, m[0])
|
remove_metadata(conn, m[0])
|
||||||
|
remove_attachment(m[0]) # remove attachments
|
||||||
print("The problem was fixed.")
|
print("The problem was fixed.")
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
@ -480,10 +504,13 @@ def export():
|
||||||
initialize_db(conn)
|
initialize_db(conn)
|
||||||
|
|
||||||
headers = {"Cookie": f"memos.access-token={Config.memo_token}"}
|
headers = {"Cookie": f"memos.access-token={Config.memo_token}"}
|
||||||
query_string = urllib.parse.urlencode(
|
# query_string = urllib.parse.urlencode(
|
||||||
{"filter": f"creator=='users/1'&&tag_search==['{tag}']"}
|
# {"filter": f"creator=='users/1'&&tag_search==['{tag}']"}
|
||||||
|
# )
|
||||||
|
query_string = urllib.parse.urlencode({"filter": f"tag in ['{tag}']"})
|
||||||
|
data = fetch_data(
|
||||||
|
f"{Config.memo_url}api/v1/users/1/memos?{query_string}", headers
|
||||||
)
|
)
|
||||||
data = fetch_data(f"{Config.memo_url}api/v1/memos?{query_string}", headers)
|
|
||||||
|
|
||||||
memos = data.get("memos", [])
|
memos = data.get("memos", [])
|
||||||
if not memos:
|
if not memos:
|
||||||
|
@ -516,6 +543,7 @@ def export():
|
||||||
diary_path=diary_path,
|
diary_path=diary_path,
|
||||||
filename=resource["filename"],
|
filename=resource["filename"],
|
||||||
headers=headers,
|
headers=headers,
|
||||||
|
metadata_id=metadata_id,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
remove_metadata(conn, metadata_id)
|
remove_metadata(conn, metadata_id)
|
||||||
|
|
|
@ -74,10 +74,11 @@ bindsym $mod+d exec --no-startup-id rofi -config ~/.config/rofi/gruvbox-soft.ras
|
||||||
exec_always --no-startup-id autotiling
|
exec_always --no-startup-id autotiling
|
||||||
|
|
||||||
# change focus
|
# change focus
|
||||||
bindsym $mod+j focus left
|
bindsym $mod+h focus left
|
||||||
bindsym $mod+k focus down
|
bindsym $mod+j focus down
|
||||||
bindsym $mod+l focus up
|
bindsym $mod+k focus up
|
||||||
bindsym $mod+semicolon focus right
|
bindsym $mod+l focus right
|
||||||
|
# bindsym $mod+semicolon focus right
|
||||||
|
|
||||||
# alternatively, you can use the cursor keys:
|
# alternatively, you can use the cursor keys:
|
||||||
bindsym $mod+Left focus left
|
bindsym $mod+Left focus left
|
||||||
|
@ -98,10 +99,10 @@ bindsym $mod+Shift+Up move up
|
||||||
bindsym $mod+Shift+Right move right
|
bindsym $mod+Shift+Right move right
|
||||||
|
|
||||||
# split in horizontal orientation
|
# split in horizontal orientation
|
||||||
bindsym $mod+h split h
|
bindsym $mod+Shift+h split h
|
||||||
|
|
||||||
# split in vertical orientation
|
# split in vertical orientation
|
||||||
bindsym $mod+v split v
|
bindsym $mod+Shift+v split v
|
||||||
|
|
||||||
# enter fullscreen mode for the focused container
|
# enter fullscreen mode for the focused container
|
||||||
bindsym $mod+f fullscreen toggle
|
bindsym $mod+f fullscreen toggle
|
||||||
|
|
Loading…
Add table
Reference in a new issue