Compare commits
5 Commits
a27ffe6ddb
...
1f989184d2
Author | SHA1 | Date | |
---|---|---|---|
1f989184d2 | |||
0bb93be1be | |||
2e3d5da34c | |||
35ae8fa2a9 | |||
51baddc8f2 |
|
@ -1,3 +1,7 @@
|
||||||
|
# WARNING!
|
||||||
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
name: Build Python Container
|
name: Build Python Container
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# WARNING!
|
||||||
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
name: Package Python
|
name: Package Python
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# WARNING!
|
||||||
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
name: Run Python tests (through Pytest)
|
name: Run Python tests (through Pytest)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# WARNING!
|
||||||
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
name: Verify Python project can be installed, loaded and have version checked
|
name: Verify Python project can be installed, loaded and have version checked
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
<!-- WARNING! -->
|
||||||
|
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
||||||
|
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
||||||
|
|
||||||
|
# Conventions
|
||||||
|
|
||||||
|
When contributing code to this project, you MUST follow the requirements
|
||||||
|
specified here.
|
||||||
|
|
||||||
|
## Code Conventions
|
||||||
|
|
||||||
When contributing code to this project, you MUST follow these principles:
|
When contributing code to this project, you MUST follow these principles:
|
||||||
|
|
||||||
- Code should be easy to read and understand.
|
- Code should be easy to read and understand.
|
||||||
|
@ -10,3 +21,16 @@ When contributing code to this project, you MUST follow these principles:
|
||||||
- Properly handle errors and exceptions to ensure the software's robustness.
|
- Properly handle errors and exceptions to ensure the software's robustness.
|
||||||
- Use exceptions rather than error codes for handling errors.
|
- Use exceptions rather than error codes for handling errors.
|
||||||
- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks.
|
- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks.
|
||||||
|
- Documentation should document semantics, not syntax.
|
||||||
|
- Prefer importing modules, not individual items from modules.
|
||||||
|
- Do not use f-strings in logging statements.
|
||||||
|
- Loop variables and walrus-expression-variables should be deleted when
|
||||||
|
unneeded to keep scope clean, and to avoid accidental use.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
When contributing test to this project, you MUST follow these principles:
|
||||||
|
|
||||||
|
- Do not use any testing libraries other than `pytest`.
|
||||||
|
- Mocking is the root of all evil. Writing your own stubs is much more
|
||||||
|
preferable.
|
||||||
|
|
14
README.md
14
README.md
|
@ -1,8 +1,6 @@
|
||||||
<!--- WARNING --->
|
<!-- WARNING! -->
|
||||||
<!--- THIS IS AN AUTO-GENERATED FILE --->
|
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
||||||
<!--- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN --->
|
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Personal Data Fetcher Systems
|
# Personal Data Fetcher Systems
|
||||||
|
|
||||||
|
@ -63,7 +61,7 @@ Full list of requirements:
|
||||||
- [lxml](https://pypi.org/project/lxml/)
|
- [lxml](https://pypi.org/project/lxml/)
|
||||||
- [requests](https://pypi.org/project/requests/)
|
- [requests](https://pypi.org/project/requests/)
|
||||||
- [requests_cache](https://pypi.org/project/requests_cache/)
|
- [requests_cache](https://pypi.org/project/requests_cache/)
|
||||||
- [browsercookie](https://pypi.org/project/browsercookie/)
|
- [browser_cookie3](https://pypi.org/project/browser_cookie3/)
|
||||||
- [cfscrape](https://github.com/landryraccoon/cloudflare-scrape)
|
- [cfscrape](https://github.com/landryraccoon/cloudflare-scrape)
|
||||||
- [frozendict](https://pypi.org/project/frozendict/)
|
- [frozendict](https://pypi.org/project/frozendict/)
|
||||||
- [python-kucoin](https://pypi.org/project/python-kucoin/)
|
- [python-kucoin](https://pypi.org/project/python-kucoin/)
|
||||||
|
@ -73,13 +71,12 @@ Full list of requirements:
|
||||||
- [fin-depo](https://gitfub.space/Jmaa/fin-depo)
|
- [fin-depo](https://gitfub.space/Jmaa/fin-depo)
|
||||||
- [secret_loader](https://gitfub.space/Jmaa/secret_loader)
|
- [secret_loader](https://gitfub.space/Jmaa/secret_loader)
|
||||||
- [requests-util](https://gitfub.space/Jmaa/requests_util)
|
- [requests-util](https://gitfub.space/Jmaa/requests_util)
|
||||||
|
- [clients](https://gitfub.space/Jmaa/clients)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
|
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
|
||||||
|
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
Testing requires the [pytest](https://docs.pytest.org/en/stable/) library.
|
Testing requires the [pytest](https://docs.pytest.org/en/stable/) library.
|
||||||
|
@ -96,7 +93,6 @@ Test coverage can be run using the [`pytest-cov`](https://pypi.org/project/pytes
|
||||||
pytest --cov=personal_data test
|
pytest --cov=personal_data test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
|
||||||
import urllib.parse
|
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
|
|
||||||
import bs4
|
|
||||||
|
|
||||||
from clients.myanimelist import MyAnimeListClient, MyAnimeListAnime, MyAnimeListSong
|
|
||||||
from clients import init_client
|
from clients import init_client
|
||||||
|
from clients.myanimelist import MyAnimeListAnime, MyAnimeListClient, MyAnimeListSong
|
||||||
|
|
||||||
from personal_data.data import DeduplicateMode, Scraper
|
from personal_data.data import DeduplicateMode, Scraper
|
||||||
|
|
||||||
from .. import secrets
|
from .. import secrets
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def client(session):
|
def client(session):
|
||||||
return init_client(MyAnimeListClient, session, secrets.secrets, throws=True)
|
return init_client(MyAnimeListClient, session, secrets.secrets, throws=True)
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class MyAnimeList(Scraper):
|
class MyAnimeList(Scraper):
|
||||||
dataset_name = 'myanimelist_anime'
|
dataset_name = 'myanimelist_anime'
|
||||||
|
|
|
@ -18,10 +18,10 @@ except ImportError:
|
||||||
logger.exception('cfscrape not installed: Certain fetchers might not work')
|
logger.exception('cfscrape not installed: Certain fetchers might not work')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import browsercookie
|
import browser_cookie3
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.exception('browsercookie not installed: Certain fetchers might not work')
|
logger.exception('browser_cookie3 not installed: Certain fetchers might not work')
|
||||||
browsercookie = None
|
browser_cookie3 = None
|
||||||
|
|
||||||
|
|
||||||
OUTPUT_PATH = Path('./output')
|
OUTPUT_PATH = Path('./output')
|
||||||
|
@ -94,11 +94,11 @@ def available_scraper_names() -> list[str]:
|
||||||
def get_cookiejar(use_cookiejar: bool):
|
def get_cookiejar(use_cookiejar: bool):
|
||||||
if use_cookiejar:
|
if use_cookiejar:
|
||||||
logger.warning('Got cookiejar from firefox')
|
logger.warning('Got cookiejar from firefox')
|
||||||
cookiejar = browsercookie.firefox()
|
cookiejar = browser_cookie3.firefox()
|
||||||
if len(cookiejar) > 10:
|
if len(cookiejar) > 10:
|
||||||
return cookiejar
|
return cookiejar
|
||||||
browsercookie.firefox(
|
browser_cookie3.firefox(
|
||||||
['/home/jmaa/.cachy/mbui5xg7.default-release/cookies.sqlite'],
|
'/home/jmaa/.cachy/mbui5xg7.default-release/cookies.sqlite'
|
||||||
)
|
)
|
||||||
if len(cookiejar) > 10:
|
if len(cookiejar) > 10:
|
||||||
return cookiejar
|
return cookiejar
|
||||||
|
|
|
@ -2,6 +2,7 @@ from secret_loader import SecretLoader
|
||||||
|
|
||||||
secrets = SecretLoader(env_key_prefix='CF_PD')
|
secrets = SecretLoader(env_key_prefix='CF_PD')
|
||||||
|
|
||||||
|
|
||||||
def load_lazy(key: str):
|
def load_lazy(key: str):
|
||||||
return lambda: secrets.load_or_fail(key)
|
return lambda: secrets.load_or_fail(key)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ beautifulsoup4
|
||||||
lxml
|
lxml
|
||||||
requests
|
requests
|
||||||
requests_cache
|
requests_cache
|
||||||
browsercookie
|
browser_cookie3
|
||||||
cfscrape @ git+https://github.com/landryraccoon/cloudflare-scrape.git
|
cfscrape @ git+https://github.com/landryraccoon/cloudflare-scrape.git
|
||||||
frozendict
|
frozendict
|
||||||
python-kucoin
|
python-kucoin
|
||||||
|
|
15
setup.py
15
setup.py
|
@ -1,8 +1,6 @@
|
||||||
# WARNING
|
# WARNING!
|
||||||
#
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
# THIS IS AN AUTOGENERATED FILE.
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
#
|
|
||||||
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN.
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -56,7 +54,6 @@ PACKAGE_DESCRIPTION_SHORT = """
|
||||||
This program collects several small data fetchers, for downloading personal
|
This program collects several small data fetchers, for downloading personal
|
||||||
data spread around the internet.""".strip()
|
data spread around the internet.""".strip()
|
||||||
|
|
||||||
|
|
||||||
def parse_version_file(text: str) -> str:
|
def parse_version_file(text: str) -> str:
|
||||||
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
||||||
if match is None:
|
if match is None:
|
||||||
|
@ -64,17 +61,15 @@ def parse_version_file(text: str) -> str:
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
return match.group(2)
|
return match.group(2)
|
||||||
|
|
||||||
|
|
||||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||||
version = parse_version_file(f.read())
|
version = parse_version_file(f.read())
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS_MAIN = [
|
REQUIREMENTS_MAIN = [
|
||||||
'beautifulsoup4',
|
'beautifulsoup4',
|
||||||
'lxml',
|
'lxml',
|
||||||
'requests',
|
'requests',
|
||||||
'requests_cache',
|
'requests_cache',
|
||||||
'browsercookie',
|
'browser_cookie3',
|
||||||
'cfscrape @ git+https://github.com/landryraccoon/cloudflare-scrape.git',
|
'cfscrape @ git+https://github.com/landryraccoon/cloudflare-scrape.git',
|
||||||
'frozendict',
|
'frozendict',
|
||||||
'python-kucoin',
|
'python-kucoin',
|
||||||
|
@ -84,12 +79,12 @@ REQUIREMENTS_MAIN = [
|
||||||
'fin-depo @ git+https://gitfub.space/Jmaa/fin-depo.git',
|
'fin-depo @ git+https://gitfub.space/Jmaa/fin-depo.git',
|
||||||
'secret_loader @ git+https://gitfub.space/Jmaa/secret_loader',
|
'secret_loader @ git+https://gitfub.space/Jmaa/secret_loader',
|
||||||
'requests-util @ git+https://gitfub.space/Jmaa/requests_util',
|
'requests-util @ git+https://gitfub.space/Jmaa/requests_util',
|
||||||
|
'clients @ git+https://gitfub.space/Jmaa/clients',
|
||||||
]
|
]
|
||||||
REQUIREMENTS_TEST = [
|
REQUIREMENTS_TEST = [
|
||||||
'pytest',
|
'pytest',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=PACKAGE_NAME,
|
name=PACKAGE_NAME,
|
||||||
version=version,
|
version=version,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user