Skip to content

Commit 5b5043d

Browse files
committed
Youtube Template works
1 parent febe5e3 commit 5b5043d

File tree

3 files changed

+18
-56
lines changed

3 files changed

+18
-56
lines changed

obsidian_cli/input.py

+17-50
Original file line numberDiff line numberDiff line change
@@ -107,72 +107,39 @@ def get_reviewed_date() -> str:
107107

108108
return f"[[{year}-{month}-{day}]]"
109109

110+
#==============================================================================#
111+
# MAIN FUNCTION
112+
#==============================================================================#
113+
114+
110115
def main():
111116
input_type = get_input_type()
112-
match input_type:
117+
match input_type[0]:
113118
case None | "q":
114119
print("Exiting...")
115120
exit()
116121
case "Video":
117-
pass # TODO HERE
118-
if input_type[0] == "Video":
119-
def youtube(input_type):
120122
file_name = get_file_name(input_type[1])
121123
file_tags = get_tags()
122124
url = get_input_url(input_type[0])
123125
youtube_shortcode = url[1]
124126
host = get_channel_host()
125127
publish_date = get_publish_date()
126128
reviewed_date = get_reviewed_date()
127-
template_video = f"""---
128-
tags: 📥️/🎥️/🟥️
129-
publish: true
130-
aliases:
131-
-
132-
cssclass:
133-
type: {input_type[0]}
134-
status: 🟥️
135-
---
136-
137-
- `Title:` [[{file_name}]]
138-
- `Type:` [[{input_type[1]}]]
139-
- `Tags:` {file_tags}
140-
- `URL:` <{url[0]}>
141-
- `Channel/Host:` [[{host}]]
142-
- `Reference:`
143-
- `Publish Date:` {publish_date}
144-
- `Reviewed Date:` {reviewed_date}
145-
146-
---
147-
148-
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/{youtube_shortcode}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center>
149-
150-
---
151-
152-
- <% tp.file.cursor(1) %>
153-
154-
"""
129+
with open('../templates/Youtube.md', 'r') as f:
130+
text = f.read()
131+
text = text.replace('{file_name}', file_name)
132+
text = text.replace('{file_tags}', file_tags)
133+
text = text.replace('{url}', url[0])
134+
text = text.replace('{youtube_shortcode}', youtube_shortcode)
135+
text = text.replace('{host}', host)
136+
text = text.replace('{publish_date}', publish_date)
137+
text = text.replace('{reviewed_date}', reviewed_date)
138+
print(text)
155139
with open(DROP_POINT_PATH + f"/{file_name}.md", "w") as file:
156-
file.write(f"{template_video}")
157-
youtube(input_type)
140+
file.write(f"{text}")
158141
# TODO add other input functions here
159142

160-
# TODO add other templates here
161-
# ============================================================================= #
162-
# TEMPLATES
163-
# ============================================================================= #
164-
165143

166144
if __name__ == "__main__":
167145
main()
168-
169-
170-
# todo refactor code with the py3.10 match statements
171-
# refactor
172-
# quit = False
173-
# match quit:
174-
# case True:
175-
# print("Quitting")
176-
# exit()
177-
# case False:
178-
# print("System is on")

obsidian_cli/test.py

-5
This file was deleted.

templates/Youtube.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ status: 🟥️
1111
- `Title:` [[{file_name}]]
1212
- `Type:` [[+]]
1313
- `Tags:` {file_tags}
14-
- `URL:` <{url[0]}>
14+
- `URL:` <{url}>
1515
- `Channel/Host:` [[{host}]]
1616
- `Reference:`
1717
- `Publish Date:` {publish_date}

0 commit comments

Comments
 (0)