fixes for file naming
formatting_check / formatting_check (push) Failing after 6s
Python Test / test (.sh, ubuntu-latest, 3.9) (push) Failing after 16s
Python Test / test (.ps1, windows-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, macos-latest, 3.9) (push) Has been cancelled
formatting_check / formatting_check (push) Failing after 6s
Python Test / test (.sh, ubuntu-latest, 3.9) (push) Failing after 16s
Python Test / test (.ps1, windows-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, macos-latest, 3.9) (push) Has been cancelled
This commit is contained in:
@@ -527,6 +527,11 @@ async def create_download_with_bdfr_api(download_type: str, name: str, **kwargs)
|
||||
progress_callbacks=[callback]
|
||||
)
|
||||
elif download_type == "user":
|
||||
# Set auth token in the BDFR manager if provided
|
||||
if auth_token:
|
||||
bdfr_manager.auth_token = auth_token
|
||||
logger.info(f"[DEBUG] Set auth token in BDFR manager for user download")
|
||||
|
||||
bdfr_download_id = bdfr_manager.download_user(
|
||||
name,
|
||||
limit=kwargs.get('limit'),
|
||||
|
||||
@@ -486,15 +486,19 @@ async def get_queue_status():
|
||||
)
|
||||
|
||||
|
||||
class UserDownloadRequest(BaseModel):
|
||||
limit: int = Field(default=25, ge=1, le=1000)
|
||||
sort: str = Field(default="hot")
|
||||
download_mode: str = Field(default="download", pattern="^(download|archive|clone)$")
|
||||
run_now: bool = Field(default=False)
|
||||
run_time: str = Field(default="02:00", pattern="^([01]?[0-9]|2[0-3]):[0-5][0-9]$")
|
||||
timezone: str = Field(default="UTC")
|
||||
auth_state: Optional[str] = None
|
||||
|
||||
|
||||
@router.post("/create-likes", response_model=ScheduledTaskResponse, status_code=status.HTTP_201_CREATED)
|
||||
async def create_likes_task(
|
||||
limit: int = 25,
|
||||
sort: str = "hot",
|
||||
download_mode: str = "download",
|
||||
run_now: bool = False,
|
||||
run_time: str = "02:00",
|
||||
timezone: str = "UTC",
|
||||
auth_state: str = None,
|
||||
request: UserDownloadRequest,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
@@ -502,14 +506,14 @@ async def create_likes_task(
|
||||
"""
|
||||
try:
|
||||
# Get current username from auth
|
||||
if not auth_state:
|
||||
if not request.auth_state:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Authentication required"
|
||||
)
|
||||
|
||||
oauth_manager = get_oauth_manager()
|
||||
auth_status = oauth_manager.get_auth_status(auth_state)
|
||||
auth_status = oauth_manager.get_auth_status(request.auth_state)
|
||||
if not auth_status["authenticated"]:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
@@ -521,15 +525,15 @@ async def create_likes_task(
|
||||
|
||||
# Validate timezone
|
||||
try:
|
||||
pytz.timezone(timezone)
|
||||
pytz.timezone(request.timezone)
|
||||
except pytz.exceptions.UnknownTimeZoneError:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Invalid timezone: {timezone}"
|
||||
detail=f"Invalid timezone: {request.timezone}"
|
||||
)
|
||||
|
||||
# Parse run_time
|
||||
hour, minute = map(int, run_time.split(':'))
|
||||
hour, minute = map(int, request.run_time.split(':'))
|
||||
run_time_obj = time_type(hour=hour, minute=minute)
|
||||
|
||||
# Create task
|
||||
@@ -538,16 +542,16 @@ async def create_likes_task(
|
||||
enabled=True,
|
||||
source_type="user",
|
||||
source_name=username,
|
||||
download_mode=download_mode,
|
||||
limit=limit,
|
||||
sort=sort,
|
||||
download_mode=request.download_mode,
|
||||
limit=request.limit,
|
||||
sort=request.sort,
|
||||
time_filter="day",
|
||||
no_dupes=True,
|
||||
simple_check=False,
|
||||
schedule_frequency="daily",
|
||||
run_time=run_time_obj,
|
||||
timezone=timezone,
|
||||
auth_state=auth_state,
|
||||
timezone=request.timezone,
|
||||
auth_state=request.auth_state,
|
||||
upvoted=True,
|
||||
saved=False
|
||||
)
|
||||
@@ -564,7 +568,7 @@ async def create_likes_task(
|
||||
schedule_task(task)
|
||||
|
||||
# If run_now is True, queue it immediately
|
||||
if run_now:
|
||||
if request.run_now:
|
||||
await task_queue.add_task(task.id, priority=1)
|
||||
|
||||
logger.info(f"Created likes task {task.id}: {task.name}")
|
||||
@@ -584,13 +588,7 @@ async def create_likes_task(
|
||||
|
||||
@router.post("/create-saved", response_model=ScheduledTaskResponse, status_code=status.HTTP_201_CREATED)
|
||||
async def create_saved_task(
|
||||
limit: int = 25,
|
||||
sort: str = "hot",
|
||||
download_mode: str = "download",
|
||||
run_now: bool = False,
|
||||
run_time: str = "02:00",
|
||||
timezone: str = "UTC",
|
||||
auth_state: str = None,
|
||||
request: UserDownloadRequest,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
@@ -598,14 +596,14 @@ async def create_saved_task(
|
||||
"""
|
||||
try:
|
||||
# Get current username from auth
|
||||
if not auth_state:
|
||||
if not request.auth_state:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Authentication required"
|
||||
)
|
||||
|
||||
oauth_manager = get_oauth_manager()
|
||||
auth_status = oauth_manager.get_auth_status(auth_state)
|
||||
auth_status = oauth_manager.get_auth_status(request.auth_state)
|
||||
if not auth_status["authenticated"]:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
@@ -617,15 +615,15 @@ async def create_saved_task(
|
||||
|
||||
# Validate timezone
|
||||
try:
|
||||
pytz.timezone(timezone)
|
||||
pytz.timezone(request.timezone)
|
||||
except pytz.exceptions.UnknownTimeZoneError:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Invalid timezone: {timezone}"
|
||||
detail=f"Invalid timezone: {request.timezone}"
|
||||
)
|
||||
|
||||
# Parse run_time
|
||||
hour, minute = map(int, run_time.split(':'))
|
||||
hour, minute = map(int, request.run_time.split(':'))
|
||||
run_time_obj = time_type(hour=hour, minute=minute)
|
||||
|
||||
# Create task
|
||||
@@ -634,16 +632,16 @@ async def create_saved_task(
|
||||
enabled=True,
|
||||
source_type="user",
|
||||
source_name=username,
|
||||
download_mode=download_mode,
|
||||
limit=limit,
|
||||
sort=sort,
|
||||
download_mode=request.download_mode,
|
||||
limit=request.limit,
|
||||
sort=request.sort,
|
||||
time_filter="day",
|
||||
no_dupes=True,
|
||||
simple_check=False,
|
||||
schedule_frequency="daily",
|
||||
run_time=run_time_obj,
|
||||
timezone=timezone,
|
||||
auth_state=auth_state,
|
||||
timezone=request.timezone,
|
||||
auth_state=request.auth_state,
|
||||
upvoted=False,
|
||||
saved=True
|
||||
)
|
||||
@@ -660,7 +658,7 @@ async def create_saved_task(
|
||||
schedule_task(task)
|
||||
|
||||
# If run_now is True, queue it immediately
|
||||
if run_now:
|
||||
if request.run_now:
|
||||
await task_queue.add_task(task.id, priority=1)
|
||||
|
||||
logger.info(f"Created saved task {task.id}: {task.name}")
|
||||
|
||||
@@ -231,8 +231,15 @@ async def execute_scheduled_task(task_id: str):
|
||||
|
||||
# For user downloads, set submitted appropriately
|
||||
if task.source_type == 'user':
|
||||
# For likes or saved, don't download submitted posts
|
||||
# For likes or saved, still need authentication but don't download submitted posts
|
||||
# Set submitted=False when downloading upvoted or saved posts
|
||||
kwargs['submitted'] = not (task.upvoted or task.saved)
|
||||
|
||||
# Ensure auth_state is passed for user downloads requiring authentication
|
||||
if task.upvoted or task.saved:
|
||||
logger.info(f"User download task {task_id} requires authentication for {'likes' if task.upvoted else 'saved'} posts")
|
||||
if not task.auth_state:
|
||||
logger.warning(f"Task {task_id} needs authentication but no auth_state provided")
|
||||
|
||||
# Create download using existing API
|
||||
download_id = await create_download_with_bdfr_api(
|
||||
|
||||
Reference in New Issue
Block a user