Renaming RecursiveHTMLDownloader to ScrapeHTMLDownloader.

This commit is contained in:
Roland 2023-08-31 08:31:19 -06:00
parent 9bb0ec6472
commit 65625e30c1
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
4 changed files with 19 additions and 19 deletions

View file

@ -430,7 +430,7 @@ class RSSDownload extends ChannelDownload {
}
}
class RecursiveDownload extends Downloader {
class ScrapeDownloader extends Downloader {
constructor(props) {
super(props);
@ -460,7 +460,7 @@ class RecursiveDownload extends Downloader {
try {
let response = await postDownload(
urls,
'recursive_html',
'scrape_html',
null,
'file',
null,
@ -498,7 +498,7 @@ class RecursiveDownload extends Downloader {
const complete = urls && depth && validSuffix && max_pages && destination;
return <Form>
<Header as='h4'><Icon name='file alternate' color='red'/> Recursive File Downloader</Header>
<Header as='h4'><Icon name='file alternate' color='red'/> Scrape File Downloader</Header>
<p>Search each of the URLs for files matching the suffix (.pdf, etc.).</p>
@ -621,9 +621,9 @@ export function DownloadMenu({onOpen, disabled}) {
/>
<Button
color='red'
content='Recursive'
content='Scrape'
disabled={disabled}
onClick={() => localOnOpen('recursive')}
onClick={() => localOnOpen('scrape')}
style={{marginBottom: '1em'}}
/>
</>);
@ -654,9 +654,9 @@ export function DownloadMenu({onOpen, disabled}) {
withSearchDirectory={true}
destinationRequired={true}
withTags={true}/>,
recursive: <RecursiveDownload
scrape: <ScrapeDownloader
clearSelected={clearSelected}
downloader='recursive'
downloader='scrape'
withSearchDirectory={true}
destinationRequired={true}
/>,

View file

@ -1,5 +1,5 @@
import wrolpi.files.api # noqa Import from files so the blueprint is attached.
import wrolpi.recursive_downloader # noqa
import wrolpi.scrape_downloader # noqa
BEFORE_STARTUP_FUNCTIONS = []

View file

@ -27,17 +27,17 @@ def resolve_url(parent_url: str, url: str):
return f'{parent_url}/{url}'
class RecursiveHTMLDownloader(Downloader):
"""Recursively downloads HTML pages searching for files with a particular suffix.
class ScrapeHTMLDownloader(Downloader):
"""Scrape downloads HTML pages searching for files with a particular suffix.
Stops recurring when depth is reached."""
name = 'recursive_html'
pretty_name = 'Recursive'
name = 'scrape_html'
pretty_name = 'Scrape'
listable = False
def __repr__(self):
return '<RecursiveHTMLDownloader>'
return '<ScrapeHTMLDownloader>'
@staticmethod
async def fetch_http(url: str) -> str:
@ -115,4 +115,4 @@ class RecursiveHTMLDownloader(Downloader):
)
recursive_html_downloader = RecursiveHTMLDownloader()
scrape_html_downloader = ScrapeHTMLDownloader()

View file

@ -4,7 +4,7 @@ import mock
from wrolpi.downloader import DownloadResult
from wrolpi.files.downloader import FileDownloader
from wrolpi.recursive_downloader import RecursiveHTMLDownloader
from wrolpi.scrape_downloader import ScrapeHTMLDownloader
EXAMPLE_HTTP = '''
<html>
@ -20,8 +20,8 @@ EXAMPLE_HTTP = '''
'''
async def test_recursive_html_downloader(test_directory, test_session, test_download_manager, assert_download_urls):
test_download_manager.register_downloader(RecursiveHTMLDownloader())
async def test_scrape_html_downloader(test_directory, test_session, test_download_manager, assert_download_urls):
test_download_manager.register_downloader(ScrapeHTMLDownloader())
test_download_manager.register_downloader(FileDownloader())
destination = test_directory / 'destination'
@ -32,7 +32,7 @@ async def test_recursive_html_downloader(test_directory, test_session, test_down
'suffix': '.pdf',
'destination': str(destination),
}
test_download_manager.create_download('https://example.com/dir', 'recursive_html', settings=settings,
test_download_manager.create_download('https://example.com/dir', 'scrape_html', settings=settings,
sub_downloader_name='file')
assert_download_urls(['https://example.com/dir', ])
@ -42,7 +42,7 @@ async def test_recursive_html_downloader(test_directory, test_session, test_down
async def fake_file_do_download(*a, **kwargs):
return DownloadResult(success=True)
with mock.patch('wrolpi.recursive_downloader.RecursiveHTMLDownloader.fetch_http', fake_fetch_http), \
with mock.patch('wrolpi.scrape_downloader.ScrapeHTMLDownloader.fetch_http', fake_fetch_http), \
mock.patch('wrolpi.files.downloader.FileDownloader.do_download', fake_file_do_download):
await test_download_manager.wait_for_all_downloads()
await asyncio.sleep(1)