Dropping channel.next_download. Removing noisy download logs.

This commit is contained in:
Roland 2021-12-27 16:43:52 -07:00
parent 22031c5860
commit f830fe3dcc
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
4 changed files with 39 additions and 10 deletions

View file

@ -0,0 +1,31 @@
"""Drop channel next_download
Revision ID: 84b6993a6091
Revises: 8df411232c17
Create Date: 2021-12-27 16:42:32.099796
"""
import os
from alembic import op
from sqlalchemy.orm import Session
# revision identifiers, used by Alembic.
revision = '84b6993a6091'
down_revision = '8df411232c17'
branch_labels = None
depends_on = None
DOCKERIZED = True if os.environ.get('DOCKER', '').lower().startswith('t') else False
def upgrade():
bind = op.get_bind()
session = Session(bind=bind)
session.execute('ALTER TABLE channel DROP COLUMN IF EXISTS next_download')
def downgrade():
bind = op.get_bind()
session = Session(bind=bind)
session.execute('ALTER TABLE channel ADD COLUMN IF NOT EXISTS next_download DATE')

View file

@ -113,6 +113,7 @@ def periodic_downloads(app: Sanic, loop):
if wrol_mode_enabled():
logger.warning(f'Not starting download worker because WROL Mode is enabled.')
return
logger.info('Starting download manager.')
# Set all downloads to new.
download_manager.reset_downloads()
@ -122,7 +123,6 @@ def periodic_downloads(app: Sanic, loop):
download_manager.delete_old_once_downloads()
await download_manager.do_downloads()
seconds = 60
logger.debug(f'Waiting {seconds} seconds to start next download')
await asyncio.sleep(seconds)
app.add_task(_periodic_download())

View file

@ -67,16 +67,18 @@ async def get_channels_video_count() -> Dict[int, int]:
return video_counts
def get_channel(source_id: str = None, link: str = None, url: str = None, return_dict: bool = True
) -> Union[dict, Channel]:
COD = Union[dict, Channel]
def get_channel(source_id: str = None, link: str = None, url: str = None, return_dict: bool = True) -> COD:
"""
Attempt to find a Channel using the provided params. The params are in order of reliability.
Raises UnknownChannel if no channel is found.
"""
with get_db_session() as session:
channel: COD = None # noqa
# Try by source_id first.
channel = None
if source_id:
channel = session.query(Channel).filter_by(source_id=source_id).one_or_none()
if not channel and link:

View file

@ -312,11 +312,6 @@ class DownloadManager:
try:
downloads = self.get_new_downloads(session)
if not downloads:
logger.info('No new downloads')
return
logger.info(f'Doing downloads.')
download_count = 0
for download in downloads:
download_count += 1
@ -350,7 +345,8 @@ class DownloadManager:
download.defer()
session_.commit()
logger.info(f'Done doing {download_count} downloads.')
if download_count:
logger.info(f'Done doing {download_count} downloads.')
finally:
session.close()