diff --git a/app/src/components/admin/Downloads.js b/app/src/components/admin/Downloads.js
index 9300eba6..b2dc6bb6 100644
--- a/app/src/components/admin/Downloads.js
+++ b/app/src/components/admin/Downloads.js
@@ -285,6 +285,7 @@ function OnceDownloadRow({download, fetchDownloads, isSelected, onSelect}) {
const [editModalOpen, setEditModalOpen] = React.useState(false);
const {url, last_successful_download, status, location, error, downloader, settings, id, tag_names} = download;
+ const parentDownloadUrl = settings?.parent_download_url;
const handleDelete = async () => {
try {
@@ -328,13 +329,23 @@ function OnceDownloadRow({download, fetchDownloads, isSelected, onSelect}) {
if (status === 'pending' || status === 'new') {
buttonCell = (
- Stop
+
+
+ {status === 'new' && (downloader === Downloaders.Video || downloader === Downloaders.Archive) && (
+
+ )}
+
);
} else if (status === 'failed' || status === 'deferred') {
@@ -411,6 +422,13 @@ function OnceDownloadRow({download, fetchDownloads, isSelected, onSelect}) {
onSuccess={handleEditSuccess}
onDelete={handleDelete}
/>
+ {parentDownloadUrl && (
+
+ From:
+ {parentDownloadUrl}
+
+
+ )}
);
@@ -433,6 +451,13 @@ function OnceDownloadRow({download, fetchDownloads, isSelected, onSelect}) {
onSuccess={handleEditSuccess}
onDelete={handleDelete}
/>
+ {parentDownloadUrl && (
+
+ From:
+ {parentDownloadUrl}
+
+
+ )}
);
diff --git a/modules/videos/test/test_downloader.py b/modules/videos/test/test_downloader.py
index 83f70872..9eb3b8ab 100644
--- a/modules/videos/test/test_downloader.py
+++ b/modules/videos/test/test_downloader.py
@@ -177,6 +177,7 @@ async def test_download_channel(test_session, test_directory, simple_channel, vi
'collection_id': simple_channel.collection_id,
'channel_url': 'https://www.youtube.com/c/LearningSelfReliance/videos',
'destination': str(test_directory),
+ 'parent_download_url': url,
}
reset_downloads()
@@ -195,6 +196,7 @@ async def test_download_channel(test_session, test_directory, simple_channel, vi
'collection_id': simple_channel.collection_id,
'channel_url': 'https://www.youtube.com/c/LearningSelfReliance/videos',
'destination': str(test_directory),
+ 'parent_download_url': url,
}
diff --git a/wrolpi/downloader.py b/wrolpi/downloader.py
index 5101f331..c8ce7ede 100644
--- a/wrolpi/downloader.py
+++ b/wrolpi/downloader.py
@@ -1265,8 +1265,10 @@ async def signal_download_download(download_id: int, download_url: str):
urls = download.filter_excluded(result.downloads) if result.downloads else None
if urls:
worker_logger.info(f'Adding {len(result.downloads)} downloads from result of {download.url}')
+ child_settings = dict(result.settings) if result.settings else {}
+ child_settings['parent_download_url'] = download.url
download_manager.create_downloads(session, urls, downloader_name=download.sub_downloader,
- settings=result.settings)
+ settings=child_settings)
if try_again is False and not download.frequency:
# Only once-downloads can fail.
diff --git a/wrolpi/schema.py b/wrolpi/schema.py
index 3836eeb4..5b3948d1 100644
--- a/wrolpi/schema.py
+++ b/wrolpi/schema.py
@@ -230,6 +230,7 @@ class DownloadSettings:
video_count_limit: Optional[int] = None
video_format: Optional[str] = None
video_resolutions: List[str] = field(default_factory=list)
+ parent_download_url: Optional[str] = None
def __post_init__(self):
if self.excluded_urls and self.excluded_urls.endswith(','):
diff --git a/wrolpi/test/test_downloader.py b/wrolpi/test/test_downloader.py
index 80b58b9c..dff7d540 100644
--- a/wrolpi/test/test_downloader.py
+++ b/wrolpi/test/test_downloader.py
@@ -802,3 +802,53 @@ async def test_batch_api_endpoints(async_client, test_session, test_download_man
body = dict(download_ids=[])
request, response = await async_client.post('/api/download/batch/delete', content=json.dumps(body))
assert response.status_code == HTTPStatus.BAD_REQUEST
+
+
+@pytest.mark.asyncio
+async def test_child_downloads_have_parent_download_url(test_session, test_download_manager, test_downloader):
+ """Child downloads spawned by a parent download should have parent_download_url set in their settings."""
+ import asyncio
+ from wrolpi.downloader import DownloadResult
+
+ parent_url = 'https://example.com/parent'
+ child_urls = ['https://example.com/child1', 'https://example.com/child2']
+
+ # Track which URLs have been processed to avoid returning children for child downloads
+ processed_urls = set()
+
+ # Configure the test_downloader to return child downloads only for the parent URL
+ async def download_with_children(download, *a, **kwargs):
+ await asyncio.sleep(0.1)
+ if download.url == parent_url and parent_url not in processed_urls:
+ processed_urls.add(parent_url)
+ return DownloadResult(success=True, downloads=child_urls)
+ # Return success without children for child downloads
+ return DownloadResult(success=True)
+
+ test_downloader.do_download.side_effect = download_with_children
+
+ # Create the parent download with a sub_downloader specified
+ test_download_manager.create_download(test_session, parent_url, test_downloader.name,
+ sub_downloader_name=test_downloader.name)
+ test_session.commit()
+
+ # Wait for the parent download to complete and create child downloads
+ await test_download_manager.wait_for_all_downloads()
+
+ # Get all downloads
+ downloads = test_session.query(Download).all()
+ assert len(downloads) == 3, f'Expected 3 downloads (1 parent + 2 children), got {len(downloads)}'
+
+ # Find parent and child downloads
+ parent_download = next((d for d in downloads if d.url == parent_url), None)
+ child_downloads = [d for d in downloads if d.url in child_urls]
+
+ assert parent_download is not None, 'Parent download not found'
+ assert len(child_downloads) == 2, f'Expected 2 child downloads, got {len(child_downloads)}'
+
+ # Verify child downloads have parent_download_url in their settings
+ for child in child_downloads:
+ assert child.settings is not None, f'Child download {child.url} has no settings'
+ assert 'parent_download_url' in child.settings, f'Child download {child.url} missing parent_download_url'
+ assert child.settings['parent_download_url'] == parent_url, \
+ f'Child download {child.url} has wrong parent_download_url: {child.settings.get("parent_download_url")}'