mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Add option to skip videos in sync_url
This commit is contained in:
parent
a519cbe05d
commit
73c3eb0984
@ -249,6 +249,9 @@ class IliasCrawler:
|
|||||||
element: bs4.Tag = soup.find(id="headerimage")
|
element: bs4.Tag = soup.find(id="headerimage")
|
||||||
if "opencast" in element.attrs["src"].lower():
|
if "opencast" in element.attrs["src"].lower():
|
||||||
PRETTY.warning(f"Switched to crawling a video at {folder_path}")
|
PRETTY.warning(f"Switched to crawling a video at {folder_path}")
|
||||||
|
if not self.dir_filter(folder_path, IliasElementType.VIDEO_FOLDER):
|
||||||
|
PRETTY.not_searching(folder_path, "user filter")
|
||||||
|
return []
|
||||||
return self._crawl_video_directory(folder_path, url)
|
return self._crawl_video_directory(folder_path, url)
|
||||||
|
|
||||||
result: List[IliasCrawlerEntry] = []
|
result: List[IliasCrawlerEntry] = []
|
||||||
|
19
sync_url.py
19
sync_url.py
@ -6,12 +6,12 @@ A simple script to download a course by name from ILIAS.
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import parse_qs, urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from PFERD import Pferd
|
from PFERD import Pferd
|
||||||
from PFERD.cookie_jar import CookieJar
|
from PFERD.cookie_jar import CookieJar
|
||||||
from PFERD.ilias.authenticators import KitShibbolethAuthenticator
|
from PFERD.ilias import (IliasCrawler, IliasElementType,
|
||||||
from PFERD.ilias.crawler import IliasCrawler
|
KitShibbolethAuthenticator)
|
||||||
from PFERD.utils import to_path
|
from PFERD.utils import to_path
|
||||||
|
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ def main() -> None:
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--test-run", action="store_true")
|
parser.add_argument("--test-run", action="store_true")
|
||||||
parser.add_argument('-c', '--cookies', nargs='?', default=None, help="File to store cookies in")
|
parser.add_argument('-c', '--cookies', nargs='?', default=None, help="File to store cookies in")
|
||||||
|
parser.add_argument('-f', '--no-videos', nargs='?', default=None, help="Don't download videos")
|
||||||
parser.add_argument('url', help="URL to the course page")
|
parser.add_argument('url', help="URL to the course page")
|
||||||
parser.add_argument('folder', nargs='?', default=None, help="Folder to put stuff into")
|
parser.add_argument('folder', nargs='?', default=None, help="Folder to put stuff into")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -47,9 +48,19 @@ def main() -> None:
|
|||||||
# Initialize pferd at the location of the script
|
# Initialize pferd at the location of the script
|
||||||
pferd = Pferd(Path(__file__).parent, test_run=args.test_run)
|
pferd = Pferd(Path(__file__).parent, test_run=args.test_run)
|
||||||
|
|
||||||
|
def dir_filter(_: Path, element: IliasElementType) -> bool:
|
||||||
|
if args.no_videos:
|
||||||
|
return element not in [IliasElementType.VIDEO_FILE, IliasElementType.VIDEO_FOLDER]
|
||||||
|
return True
|
||||||
|
|
||||||
pferd.enable_logging()
|
pferd.enable_logging()
|
||||||
# fetch
|
# fetch
|
||||||
pferd.ilias_kit_folder(target=folder, full_url=args.url, cookies=args.cookies)
|
pferd.ilias_kit_folder(
|
||||||
|
target=folder,
|
||||||
|
full_url=args.url,
|
||||||
|
cookies=args.cookies,
|
||||||
|
dir_filter=dir_filter
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user