Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
malinkang committed Feb 6, 2024
1 parent c88a564 commit f007ad6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/douban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
sync:
name: Sync
runs-on: ubuntu-latest
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTION_PAGE: ${{ secrets.NOTION_PAGE }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -22,4 +25,4 @@ jobs:
pip install -r requirements.txt
- name: douban sync
run: |
python scripts/douban.py
python -u scripts/douban.py
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
requests
notion-client
github-heatmap
retrying
pendulum
2 changes: 1 addition & 1 deletion scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# "ISBN":RICH_TEXT,
# "链接":URL,
"导演":RELATION,
"演员":RELATION,
"演员":MULTI_SELECT,
# "Sort":NUMBER,
"封面":FILES,
"分类":RELATION,
Expand Down
9 changes: 2 additions & 7 deletions scripts/douban.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def fetch_subjects(user, type_, status):
print(f"notion {len(notion_movie_dict)}")
results = []
for i in status.keys():
results.extend(fetch_subjects("malinkang", "movie", "done"))
results.extend(fetch_subjects("malinkang", "movie", i))
for result in results:
movie = {}
subject = result.get("subject")
Expand Down Expand Up @@ -132,12 +132,7 @@ def fetch_subjects(user, type_, status):
for x in subject.get("genres")
]
if subject.get("actors"):
movie["演员"] = [
notion_helper.get_relation_id(
x.get("name"), notion_helper.actor_database_id, USER_ICON_URL
)
for x in subject.get("actors")[0:100]
]
movie["演员"] = subject.get("actors")[0:100]
if subject.get("directors"):
movie["导演"] = [
notion_helper.get_relation_id(
Expand Down
5 changes: 4 additions & 1 deletion scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
STATUS,
TITLE,
SELECT,
MULTI_SELECT
)
import pendulum

Expand Down Expand Up @@ -254,7 +255,9 @@ def get_properties(dict1, dict2):
elif type==URL:
property = {"url": value}
elif type==SELECT:
property = {"select": {"name": value}}
property = {"select": {"name": value}}
elif type==MULTI_SELECT:
property = {"multi_select": [{"name": name} for name in value]}
elif type == RELATION:
property = {"relation": [{"id": id} for id in value]}
if property:
Expand Down

0 comments on commit f007ad6

Please sign in to comment.