Skip to content

Commit 61f7a70

Browse files
committed
- fixed downloading webp pins
- fixed downloading pins in general - added http2 support - added proxy support - added brotli compression support - better headers - improved networking
1 parent 77b15a0 commit 61f7a70

File tree

8 files changed

+52
-32
lines changed

8 files changed

+52
-32
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Spankbang API test
1+
name: Sex API test
22

33
on:
44
push:
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install pytest bs4 git+https://github.com/EchterAlsFake/eaf_base_api
26+
pip install -r requirements.txt --upgrade
2727
- name: Test with pytest
2828
run: |
2929
pytest

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include README.md
2+
include LICENSE

README/Changelog.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,14 @@
99

1010
# 1.3-1
1111
- switched to httpx
12-
- removed requests from dependencies
12+
- removed requests from dependencies
13+
14+
# 1.3.4
15+
- fixed downloading webp pins
16+
- fixed downloading pins in general
17+
- added http2 support
18+
- added proxy support
19+
- added brotli compression support
20+
- better headers
21+
- improved networking
22+
- fixed tests

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[build-system]
2+
requires = ["setuptools>=61", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "Sex_API"
7+
version = "1.3.4"
8+
description = "A Python API for the Porn Site Sex.com/pins"
9+
readme = { file = "README.md", content-type = "text/markdown" }
10+
authors = [{ name = "Johannes Habel", email = "EchterAlsFake@proton.me" }]
11+
license = { file = "LICENSE" }
12+
dependencies = ["eaf_base_api"]
13+
classifiers = [
14+
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
15+
"Programming Language :: Python",
16+
]
17+
18+
[project.urls]
19+
Homepage = "https://github.com/EchterAlsFake/Sex_API"
20+
21+
[project.scripts]
22+
sex_api = "sex_api.api:main"
23+
24+
# Optional: make package discovery explicit (helps older setuptools)
25+
[tool.setuptools.packages.find]
26+
include = ["sex_api*"]

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eaf_base_api
2+
h2
3+
brotli

setup.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

sex_api/api.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import os
22
import html
3-
import logging
43
import argparse
54

65
from typing import Generator
76
from base_api.base import BaseCore
87
from functools import cached_property
9-
from base_api.modules import config
108

119
try:
1210
from modules.errors import *
@@ -135,8 +133,7 @@ def download(self, path) -> bool:
135133
raise NotSupported("Sorry, but downloading this Pin is not supported. Remember, Clips (videos) are not "
136134
"supported by this API!")
137135

138-
content = self.core.fetch(url=self.embed_url)
139-
download_content = content.content
136+
download_content = self.core.fetch(url=self.embed_url, get_bytes=True)
140137
name = self.name
141138

142139
if not str(path).endswith(os.sep):
@@ -148,6 +145,9 @@ def download(self, path) -> bool:
148145
elif ".jpg" in self.embed_url:
149146
file = open(f"{path}{name}.jpg", "wb")
150147

148+
elif ".webp" in self.embed_url:
149+
file = open(f"{path}{name}.webp", "wb")
150+
151151
else:
152152
return False
153153

@@ -364,4 +364,6 @@ def main():
364364

365365

366366
if __name__ == "__main__":
367-
main()
367+
clint = Client()
368+
pin = clint.get_pin("https://www.sex.com/en/gifs/675187")
369+
pin.download("./")

sex_api/tests/test_board.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ..api import Client
22

33
client = Client()
4-
board = client.get_board("https://www.sex.com/user/keymatt22/cum-on/")
4+
board = client.get_board("https://www.sex.com/user/keymatt22/my-personal-favs/")
55

66

77
def test_board_attributes():

0 commit comments

Comments
 (0)