mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
98834c9c95 | |||
55e9e719ad |
@ -26,6 +26,10 @@ LOGGER = logging.getLogger(__name__)
|
|||||||
PRETTY = PrettyLogger(LOGGER)
|
PRETTY = PrettyLogger(LOGGER)
|
||||||
|
|
||||||
|
|
||||||
|
def _sanitize_path_name(name: str) -> str:
|
||||||
|
return name.replace("/", "-")
|
||||||
|
|
||||||
|
|
||||||
class IliasElementType(Enum):
|
class IliasElementType(Enum):
|
||||||
"""
|
"""
|
||||||
The type of an ilias element.
|
The type of an ilias element.
|
||||||
@ -260,7 +264,7 @@ class IliasCrawler:
|
|||||||
links: List[bs4.Tag] = soup.select("a.il_ContainerItemTitle")
|
links: List[bs4.Tag] = soup.select("a.il_ContainerItemTitle")
|
||||||
for link in links:
|
for link in links:
|
||||||
abs_url = self._abs_url_from_link(link)
|
abs_url = self._abs_url_from_link(link)
|
||||||
element_path = Path(folder_path, link.getText().strip())
|
element_path = Path(folder_path, _sanitize_path_name(link.getText().strip()))
|
||||||
element_type = self._find_type_from_link(element_path, link, abs_url)
|
element_type = self._find_type_from_link(element_path, link, abs_url)
|
||||||
|
|
||||||
if element_type == IliasElementType.REGULAR_FILE:
|
if element_type == IliasElementType.REGULAR_FILE:
|
||||||
@ -377,7 +381,7 @@ class IliasCrawler:
|
|||||||
modification_date = demangle_date(modification_date_str)
|
modification_date = demangle_date(modification_date_str)
|
||||||
|
|
||||||
# Grab the name from the link text
|
# Grab the name from the link text
|
||||||
name = link_element.getText()
|
name = _sanitize_path_name(link_element.getText())
|
||||||
full_path = Path(path, name + "." + file_type)
|
full_path = Path(path, name + "." + file_type)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -508,7 +512,7 @@ class IliasCrawler:
|
|||||||
).getText().strip()
|
).getText().strip()
|
||||||
title += ".mp4"
|
title += ".mp4"
|
||||||
|
|
||||||
video_path: Path = Path(parent_path, title)
|
video_path: Path = Path(parent_path, _sanitize_path_name(title))
|
||||||
|
|
||||||
video_url = self._abs_url_from_link(link)
|
video_url = self._abs_url_from_link(link)
|
||||||
|
|
||||||
@ -580,6 +584,7 @@ class IliasCrawler:
|
|||||||
# Two divs, side by side. Left is the name, right is the link ==> get left
|
# Two divs, side by side. Left is the name, right is the link ==> get left
|
||||||
# sibling
|
# sibling
|
||||||
file_name = file_link.parent.findPrevious(name="div").getText().strip()
|
file_name = file_link.parent.findPrevious(name="div").getText().strip()
|
||||||
|
file_name = _sanitize_path_name(file_name)
|
||||||
url = self._abs_url_from_link(file_link)
|
url = self._abs_url_from_link(file_link)
|
||||||
|
|
||||||
LOGGER.debug("Found file %r at %r", file_name, url)
|
LOGGER.debug("Found file %r at %r", file_name, url)
|
||||||
|
@ -37,7 +37,7 @@ Ensure that you have at least Python 3.8 installed.
|
|||||||
To install PFERD or update your installation to the latest version, run this
|
To install PFERD or update your installation to the latest version, run this
|
||||||
wherever you want to install or have already installed PFERD:
|
wherever you want to install or have already installed PFERD:
|
||||||
```
|
```
|
||||||
$ pip install git+https://github.com/Garmelon/PFERD@v2.4.3
|
$ pip install git+https://github.com/Garmelon/PFERD@v2.4.4
|
||||||
```
|
```
|
||||||
|
|
||||||
The use of [venv] is recommended.
|
The use of [venv] is recommended.
|
||||||
@ -60,8 +60,8 @@ $ mkdir Vorlesungen
|
|||||||
$ cd Vorlesungen
|
$ cd Vorlesungen
|
||||||
$ python3 -m venv .venv
|
$ python3 -m venv .venv
|
||||||
$ .venv/bin/activate
|
$ .venv/bin/activate
|
||||||
$ pip install git+https://github.com/Garmelon/PFERD@v2.4.3
|
$ pip install git+https://github.com/Garmelon/PFERD@v2.4.4
|
||||||
$ curl -O https://raw.githubusercontent.com/Garmelon/PFERD/v2.4.3/example_config.py
|
$ curl -O https://raw.githubusercontent.com/Garmelon/PFERD/v2.4.4/example_config.py
|
||||||
$ python3 example_config.py
|
$ python3 example_config.py
|
||||||
$ deactivate
|
$ deactivate
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user