Skip to content

Commit

Permalink
Update retrieve_writefreely.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
taniki committed Nov 7, 2024
1 parent 06e8f2e commit 1d624ad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/retrieve_writefreely.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
steps:
- uses: "actions/checkout@v4"
with:
ref: ${{ github.head_ref }}
ref: ${{ github.ref_name }}
- uses: "actions/setup-python@v2"
with:
python-version: "3.9"
python-version: "3.12"
- name: "go to `./scripts`"
run: |
cd scripts
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions scripts/import_wf_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import requests
import frontmatter

from dateutil import parser
import datetime
import pytz

# %%
source = 'https://write.apreslanu.it/api/collections/offload/posts'
Expand Down Expand Up @@ -51,9 +52,10 @@ def get_posts():

# %%
def write_posts(posts):
tz = pytz.timezone('Europe/Paris')

for p in posts:
filename = parser.parse(p['created']).strftime('%s')
filename = datetime.datetime.fromisoformat(p['created'][:19]+"Z").astimezone(tz).strftime('%s')
url = source.replace('/api/collections', '').replace('posts', p['slug'])

post = frontmatter.Post(
Expand All @@ -64,6 +66,7 @@ def write_posts(posts):
)

print(filename)
print(p['created'])
print(post['title'])
print(post['source'])

Expand Down
6 changes: 4 additions & 2 deletions scripts/import_wf_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import requests
import frontmatter

from dateutil import parser
import datetime
import pytz

# %%
source = 'https://write.apreslanu.it/api/collections/tk/posts'
Expand Down Expand Up @@ -51,9 +52,10 @@ def get_posts():

# %%
def write_posts(posts):
tz = pytz.timezone('Europe/Paris')

for p in posts:
filename = parser.parse(p['created']).strftime('%s')
filename = datetime.datetime.fromisoformat(p['created']).astimezone(tz).strftime('%s')
url = source.replace('/api/collections', '').replace('posts', p['slug'])

post = frontmatter.Post(
Expand Down
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests
python-frontmatter
python-dateutil
pytz

0 comments on commit 1d624ad

Please sign in to comment.