Skip to content

Commit 1feb9e0

Browse files
Merge pull request #19
v3.11.11
2 parents 7cb3eef + fc42829 commit 1feb9e0

10 files changed

Lines changed: 237 additions & 275 deletions

File tree

.github/workflows/publish.yml

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -71,53 +71,53 @@ jobs:
7171
name: dist
7272
path: dist
7373

74-
# release:
75-
# name: Release
76-
# runs-on: ubuntu-latest
77-
# needs: publish
78-
# steps:
79-
# - uses: actions/checkout@v4
80-
# with:
81-
# fetch-depth: 0
82-
# - name: Get dist
83-
# uses: actions/download-artifact@v4
84-
# with:
85-
# name: dist
86-
# path: dist
87-
# - name: Get Tag
88-
# id: tag
89-
# uses: olegtarasov/get-tag@v2.1.1
90-
# - name: Clean CHANGELOG.md
91-
# run: |
92-
# touch CHANGELOG.md.tmp
93-
# npm install -g prettier
94-
# prettier --parser markdown --tab-width 4 --prose-wrap never CHANGELOG.md > CHANGELOG.md.tmp
95-
# cat CHANGELOG.md.tmp > CHANGELOG.md
96-
# - name: Build Release
97-
# id: release
98-
# uses: MatteoCampinoti94/changelog-to-release@v1.0.2
99-
# with:
100-
# version-name: ${{ steps.tag.outputs.tag }}
101-
# - name: Build Release File
102-
# env:
103-
# TAG: ${{ steps.tag.outputs.tag }}
104-
# RELEASE: ${{ steps.release.outputs.body }}
105-
# run: |
106-
# touch RELEASE.md
107-
# PREVIOUS_TAG="$(git tag -l --sort=-version:refname | head -2 | tail -1)"
108-
# printf "%s\n" "$RELEASE" > RELEASE.md
109-
# printf "\n## 🔗 Links\n" >> RELEASE.md
110-
# printf "\n* %s" "PyPi release: https://pypi.org/project/${GITHUB_REPOSITORY#*/}/${TAG#v}" >> RELEASE.md
111-
# printf "\n* %s" "Full changelog: https://github.com/$GITHUB_REPOSITORY/compare/$PREVIOUS_TAG...$TAG" >> RELEASE.md
112-
# cat RELEASE.md
113-
# printf "\n\n## Dist Files\n"
114-
# ls -l dist || echo " no files"
115-
# - name: Create Release
116-
# uses: softprops/action-gh-release@v1
117-
# with:
118-
# token: ${{ secrets.GITHUB_TOKEN }}
119-
# tag_name: ${{ steps.tag.outputs.tag }}
120-
# name: ${{ steps.release.outputs.title }}
121-
# body_path: RELEASE.md
122-
# files: |
123-
# dist/*
74+
release:
75+
name: Release
76+
runs-on: ubuntu-latest
77+
needs: publish
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
- name: Get dist
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: dist
86+
path: dist
87+
- name: Get Tag
88+
id: tag
89+
uses: olegtarasov/get-tag@v2.1.1
90+
- name: Clean CHANGELOG.md
91+
run: |
92+
touch CHANGELOG.md.tmp
93+
npm install -g prettier
94+
prettier --parser markdown --tab-width 4 --prose-wrap never CHANGELOG.md > CHANGELOG.md.tmp
95+
cat CHANGELOG.md.tmp > CHANGELOG.md
96+
- name: Build Release
97+
id: release
98+
uses: MatteoCampinoti94/changelog-to-release@v1.0.6
99+
with:
100+
version-name: ${{ steps.tag.outputs.tag }}
101+
- name: Build Release File
102+
env:
103+
TAG: ${{ steps.tag.outputs.tag }}
104+
RELEASE: ${{ steps.release.outputs.body }}
105+
run: |
106+
touch RELEASE.md
107+
PREVIOUS_TAG="$(git tag -l --sort=-version:refname | head -2 | tail -1)"
108+
printf "%s\n" "$RELEASE" > RELEASE.md
109+
printf "\n## 🔗 Links\n" >> RELEASE.md
110+
printf "\n* %s" "PyPi release: https://pypi.org/project/${GITHUB_REPOSITORY#*/}/${TAG#v}" >> RELEASE.md
111+
printf "\n* %s" "Full changelog: https://github.com/$GITHUB_REPOSITORY/compare/$PREVIOUS_TAG...$TAG" >> RELEASE.md
112+
cat RELEASE.md
113+
printf "\n\n## Dist Files\n"
114+
ls -l dist || echo " no files"
115+
- name: Create Release
116+
uses: softprops/action-gh-release@v1
117+
with:
118+
token: ${{ secrets.GITHUB_TOKEN }}
119+
tag_name: ${{ steps.tag.outputs.tag }}
120+
name: ${{ steps.release.outputs.title }}
121+
body_path: RELEASE.md
122+
files: |
123+
dist/*

.github/workflows/test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: Test
22

33
on:
44
push:
5-
branches: [ main, dev ]
65
pull_request:
7-
branches: [ main, dev ]
86
schedule:
97
- cron: '0 7 * * *'
108
workflow_dispatch:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## v3.11.11
4+
5+
### Fixes
6+
7+
* Fix `FAAPI.login_status` and `FAAPI.me` not working due to /login not being allowed by FurAffinity's robots.txt.
8+
9+
### Dependencies
10+
11+
* Use [requests ^2.32.5](https://pypi.org/project/requests/2.32.5)
12+
* Use [beautifulsoup4 ^4.13.5](https://pypi.org/project/beautifulsoup4/4.13.5)
13+
* Use [lxml ^6.0.1](https://pypi.org/project/lxml/6.0.1)
14+
315
## v3.11.10
416

517
### Changes

faapi/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.11.10"
1+
__version__ = "3.11.11"

faapi/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def login_status(self) -> bool:
116116
117117
:return: True if the cookies belong to a login session, False otherwise.
118118
"""
119-
return parse_loggedin_user(self.get_parsed("login", skip_auth_check=True)) is not None
119+
return parse_loggedin_user(self.get_parsed("/", skip_auth_check=True)) is not None
120120

121121
def get(self, path: str, **params: Union[str, bytes, int, float]) -> Response:
122122
"""
@@ -158,7 +158,7 @@ def me(self) -> Optional[User]:
158158
159159
:return: A User object for the logged-in user, or None if the cookies are not from a login session.
160160
"""
161-
return self.user(user) if (user := parse_loggedin_user(self.get_parsed("login"))) else None
161+
return self.user(user) if (user := parse_loggedin_user(self.get_parsed("/"))) else None
162162

163163
def frontpage(self) -> list[SubmissionPartial]:
164164
"""

faapi/parse.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,30 @@ def html_to_bbcode(html: str) -> str:
9090
return ""
9191

9292
for linkusername in body.select("a.linkusername"):
93-
linkusername.replaceWith(f"@{linkusername.text.strip()}")
93+
linkusername.replace_with(f"@{linkusername.text.strip()}")
9494

9595
for iconusername in body.select("a.iconusername,a.usernameicon"):
9696
username: str = iconusername.text.strip() or iconusername.attrs.get('href', '').strip('/').split('/')[-1]
9797
if icon := iconusername.select_one("img"):
9898
username = icon.attrs.get('alt', '').strip() or username
99-
iconusername.replaceWith(f":icon{username}:" if iconusername.text.strip() else f":{username}icon:")
99+
iconusername.replace_with(f":icon{username}:" if iconusername.text.strip() else f":{username}icon:")
100100

101101
for img in body.select("img"):
102-
img.replaceWith(f"[img={img.attrs.get('src', '')}/]")
102+
img.replace_with(f"[img={img.attrs.get('src', '')}/]")
103103

104104
for hr in body.select("hr"):
105-
hr.replaceWith("-----")
105+
hr.replace_with("-----")
106106

107107
for smilie in body.select("i.smilie"):
108108
smilie_class: list[str] = list(smilie.attrs.get("class", []))
109109
smilie_name: str = next(filter(lambda c: c not in ["smilie", ""], smilie_class), "")
110-
smilie.replaceWith(f":{smilie_name or 'smilie'}:")
110+
smilie.replace_with(f":{smilie_name or 'smilie'}:")
111111

112112
for span in body.select("span.bbcode[style*=color]"):
113113
if m := match(r".*color: ?([^ ;]+).*", span.attrs["style"]):
114-
span.replaceWith(f"[color={m[1]}]", *span.children, "[/color]")
114+
span.replace_with(f"[color={m[1]}]", *span.children, "[/color]")
115115
else:
116-
span.replaceWith(*span.children)
116+
span.replace_with(*span.children)
117117

118118
for nav_link in body.select("span.parsed_nav_links"):
119119
a_tags = nav_link.select("a")
@@ -123,37 +123,37 @@ def html_to_bbcode(html: str) -> str:
123123
a_prev = a_prev_tag.attrs.get("href", "").strip("/").split("/")[-1] if a_prev_tag else ""
124124
a_frst = a_frst_tag.attrs.get("href", "").strip("/").split("/")[-1] if a_frst_tag else ""
125125
a_next = a_next_tag.attrs.get("href", "").strip("/").split("/")[-1] if a_next_tag else ""
126-
nav_link.replaceWith(f"[{a_prev or '-'},{a_frst or '-'},{a_next or '-'}]")
126+
nav_link.replace_with(f"[{a_prev or '-'},{a_frst or '-'},{a_next or '-'}]")
127127

128128
for a in body.select("a.auto_link_shortened:not(.named_url), a.auto_link:not(.named_url)"):
129-
a.replaceWith(a.attrs.get('href', ''))
129+
a.replace_with(a.attrs.get('href', ''))
130130

131131
for a in body.select("a"):
132132
href_match: Optional[Match] = relative_url.match(a.attrs.get('href', ''))
133-
a.replaceWith(
133+
a.replace_with(
134134
f"[url={href_match[1] if href_match else a.attrs.get('href', '')}]",
135135
*a.children,
136136
"[/url]"
137137
)
138138

139139
for yt in body.select("iframe[src*='youtube.com/embed']"):
140-
yt.replaceWith(f"[yt]https://youtube.com/embed/{yt.attrs.get('src', '').strip('/').split('/')}[/yt]")
140+
yt.replace_with(f"[yt]https://youtube.com/embed/{yt.attrs.get('src', '').strip('/').split('/')}[/yt]")
141141

142142
for quote_name_tag in body.select("span.bbcode.bbcode_quote > span.bbcode_quote_name"):
143143
quote_author: str = quote_name_tag.text.strip().removesuffix('wrote:').strip()
144144
quote_tag = quote_name_tag.parent
145145
if not quote_tag:
146-
quote_name_tag.replaceWith(quote_author)
146+
quote_name_tag.replace_with(quote_author)
147147
continue
148148
quote_name_tag.decompose()
149-
quote_tag.replaceWith(
149+
quote_tag.replace_with(
150150
f"[quote{('=' + quote_author) if quote_author else ''}]",
151151
*quote_tag.children,
152152
"[/quote]"
153153
)
154154

155155
for quote_tag in body.select("span.bbcode.bbcode_quote"):
156-
quote_tag.replaceWith("[quote]", *quote_tag.children, "[/quote]")
156+
quote_tag.replace_with("[quote]", *quote_tag.children, "[/quote]")
157157

158158
for [selector, bbcode_tag] in (
159159
("i", "i"),
@@ -175,19 +175,19 @@ def html_to_bbcode(html: str) -> str:
175175
("h6", "h6"),
176176
):
177177
for tag in body.select(selector):
178-
tag.replaceWith(f"[{bbcode_tag}]", *tag.children, f"[/{bbcode_tag}]")
178+
tag.replace_with(f"[{bbcode_tag}]", *tag.children, f"[/{bbcode_tag}]")
179179

180180
for br in body.select("br"):
181-
br.replaceWith("\n")
181+
br.replace_with("\n")
182182

183183
for p in body.select("p"):
184-
p.replaceWith(*p.children)
184+
p.replace_with(*p.children)
185185

186186
for tag in body.select("*"):
187187
if not (div_class := tag.attrs.get("class", None)):
188-
tag.replaceWith(f"[tag={tag.name}]", *tag.children, "[/tag.{tag.name}]")
188+
tag.replace_with(f"[tag={tag.name}]", *tag.children, "[/tag.{tag.name}]")
189189
else:
190-
tag.replaceWith(
190+
tag.replace_with(
191191
f"[tag={tag.name}.{' '.join(div_class) if isinstance(div_class, list) else div_class}]",
192192
*tag.children,
193193
"[/tag]"
@@ -245,12 +245,12 @@ def parse_extra(page: BeautifulSoup) -> BeautifulSoup:
245245
if m_ := match(rf"(.*):({'|'.join(smilie_icons)}):(.*)", child):
246246
has_match = True
247247
child_new = Tag(name="i", attrs={"class": f"smilie {m_[2]}"})
248-
child.replaceWith(m_[1], child_new, m_[3])
248+
child.replace_with(m_[1], child_new, m_[3])
249249
elif m_ := match(r"(.*)(?:@([a-zA-Z0-9.~_-]+)|:link([a-zA-Z0-9.~_-]+):)(.*)", child):
250250
has_match = True
251251
child_new = Tag(name="a", attrs={"class": "linkusername", "href": f"/user/{m_[2] or m_[3]}"})
252252
child_new.insert(0, m_[2] or m_[3])
253-
child.replaceWith(m_[1], child_new, m_[4])
253+
child.replace_with(m_[1], child_new, m_[4])
254254
elif m_ := match(r"(.*):(?:icon([a-zA-Z0-9.~_-]+)|([a-zA-Z0-9.~_-]+)icon):(.*)", child):
255255
has_match = True
256256
user: str = m_[2] or m_[3] or ""
@@ -265,7 +265,7 @@ def parse_extra(page: BeautifulSoup) -> BeautifulSoup:
265265
child_new.insert(0, child_new_img)
266266
if m_[2]:
267267
child_new.insert(1, f"\xA0{m_[2]}")
268-
child.replaceWith(m_[1], child_new, m_[4])
268+
child.replace_with(m_[1], child_new, m_[4])
269269
elif m_ := match(r"(.*)\[ *(?:(\d+)|-)?, *(?:(\d+)|-)? *, *(?:(\d+)|-)? *](.*)", child):
270270
has_match = True
271271
child_new = Tag(name="span", attrs={"class": "parsed_nav_links"})
@@ -286,10 +286,10 @@ def parse_extra(page: BeautifulSoup) -> BeautifulSoup:
286286
child_new.insert(2, child_new_2)
287287
child_new.insert(3, "\xA0|\xA0")
288288
child_new.insert(4, child_new_3)
289-
child.replaceWith(m_[1], child_new, m_[5])
289+
child.replace_with(m_[1], child_new, m_[5])
290290

291291
for p in page.select("p"):
292-
p.replaceWith(*p.children)
292+
p.replace_with(*p.children)
293293

294294
return page
295295

0 commit comments

Comments
 (0)