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 clipboard=unnamed " use system clipboard
|
||||
set clipboard=unnamedplus
|
||||
set clipboard=unnamed " use system clipboard
|
||||
" set clipboard=unnamedplus
|
||||
|
||||
set exrc " enable usage of additional .vimrc files from working directory
|
||||
set secure " prohibit .vimrc files to execute shell, create files, etc...
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import base64
|
||||
|
||||
# import cProfile
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
# import pstats
|
||||
import re
|
||||
import shlex
|
||||
|
@ -106,9 +108,9 @@ def convert_diary_date(date_str):
|
|||
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]
|
||||
filename = f"{int(time.time())}_{filename}"
|
||||
filename = f"id{metadata_id}_{int(time.time())}_{filename}"
|
||||
if not Path(diary_path / FILES_PATH).exists():
|
||||
Path(diary_path / FILES_PATH).mkdir(parents=True, exist_ok=True)
|
||||
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_headers,
|
||||
data={
|
||||
"from": "1970-01-01",
|
||||
"limit": 20,
|
||||
"from": datetime.fromtimestamp(int(time.time()) - 2592000).strftime(
|
||||
"%Y-%m-%d"
|
||||
), # 30 days
|
||||
# "limit": 1000,
|
||||
"device": Config.geo_device,
|
||||
"user": Config.geo_user,
|
||||
},
|
||||
|
@ -418,6 +422,25 @@ def doctor():
|
|||
print(e)
|
||||
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):
|
||||
conn = db_connection(diary_path)
|
||||
diary_datetime, result = check_jrnl(metadata=m)
|
||||
|
@ -432,6 +455,7 @@ def doctor():
|
|||
)
|
||||
else:
|
||||
remove_metadata(conn, m[0])
|
||||
remove_attachment(m[0]) # remove attachments
|
||||
print("The problem was fixed.")
|
||||
conn.close()
|
||||
|
||||
|
@ -480,10 +504,13 @@ def export():
|
|||
initialize_db(conn)
|
||||
|
||||
headers = {"Cookie": f"memos.access-token={Config.memo_token}"}
|
||||
query_string = urllib.parse.urlencode(
|
||||
{"filter": f"creator=='users/1'&&tag_search==['{tag}']"}
|
||||
# query_string = urllib.parse.urlencode(
|
||||
# {"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", [])
|
||||
if not memos:
|
||||
|
@ -516,6 +543,7 @@ def export():
|
|||
diary_path=diary_path,
|
||||
filename=resource["filename"],
|
||||
headers=headers,
|
||||
metadata_id=metadata_id,
|
||||
)
|
||||
except Exception:
|
||||
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
|
||||
|
||||
# change focus
|
||||
bindsym $mod+j focus left
|
||||
bindsym $mod+k focus down
|
||||
bindsym $mod+l focus up
|
||||
bindsym $mod+semicolon focus right
|
||||
bindsym $mod+h focus left
|
||||
bindsym $mod+j focus down
|
||||
bindsym $mod+k focus up
|
||||
bindsym $mod+l focus right
|
||||
# bindsym $mod+semicolon focus right
|
||||
|
||||
# alternatively, you can use the cursor keys:
|
||||
bindsym $mod+Left focus left
|
||||
|
@ -98,10 +99,10 @@ bindsym $mod+Shift+Up move up
|
|||
bindsym $mod+Shift+Right move right
|
||||
|
||||
# split in horizontal orientation
|
||||
bindsym $mod+h split h
|
||||
bindsym $mod+Shift+h split h
|
||||
|
||||
# split in vertical orientation
|
||||
bindsym $mod+v split v
|
||||
bindsym $mod+Shift+v split v
|
||||
|
||||
# enter fullscreen mode for the focused container
|
||||
bindsym $mod+f fullscreen toggle
|
||||
|
|
Loading…
Add table
Reference in a new issue