-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipee_iina.py
78 lines (60 loc) · 2.08 KB
/
clipee_iina.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'''
Complement script to the "Screenshot IINA" Apple Shortcuts.
- moves file to notes folder
- renames file
- copy HTML to clipboard
'''
import subprocess
# from inspect import currentframe
import os
import time
start_time = time.time()
import time
import os
import subprocess
from dotenv import load_dotenv
load_dotenv()
IINA_OUTPUT_FOLDER = os.getenv("IINA_OUTPUT_FOLDER")
import sys
import pymsgbox
output_folder = ''
### Functions
def write_to_clipboard(output):
process = subprocess.Popen(
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode('utf-8'))
print(f"\nOUTPUT COPIED TO CLIPBOARD\n")
def process_iina_screenshot(filepath, v=False, test=False):
if test:
pymsgbox.alert(f"\nStarting process_iina_screenshot with {filepath}\n")
image_path = filepath.replace(IINA_OUTPUT_FOLDER, '')[1:]
if v:
pymsgbox.alert(f"\n{image_path=}")
if image_path not in [None, 'None', '']:
image_name = image_path.split('.')[0]
if image_name.endswith('-'):
image_name.replace('-', '')
if v:
pymsgbox.alert(f"\n{image_name=}")
output = f"<img class=\"screenshot\" src=\"https://notes.nicolasdeville.com/images/{image_path}\" alt=\"{image_name}\"/>"
if v:
pymsgbox.alert(f"\n{output=}")
write_to_clipboard(output)
run_time = round((time.time() - start_time), 1)
print(f'finished in {run_time}s.\n')
########################################################################################################
if __name__ == '__main__':
print()
filepath = sys.argv[1]
# process_iina_screenshot(filepath, v=True, test=True)
process_iina_screenshot(filepath)
print()
print('-------------------------------')
print(f"{os.path.basename(__file__)}")
print()
run_time = round((time.time() - start_time), 1)
if run_time > 60:
print(f'{os.path.basename(__file__)} finished in {run_time/60} minutes.')
else:
print(f'{os.path.basename(__file__)} finished in {run_time}s.')
print()