diff --git a/.bumpversion.cfg b/.bumpversion.cfg index e01dcc4..1da39e5 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.0 +current_version = 0.1.1 commit = True tag = True diff --git a/deploy/Dockerfile b/deploy/Dockerfile index b22b23d..c997332 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -9,8 +9,7 @@ FROM python:3.10 ARG TARGETPLATFORM COPY --from=0 /build/dist /install -RUN pip install -- /install/*.whl gunicorn honcho && \ - rm -rf ~/.cache/pip +RUN pip install -- /install/*.whl gunicorn honcho # ffmpeg static source (https://johnvansickle.com/ffmpeg/) RUN set -e; \ diff --git a/pyproject.toml b/pyproject.toml index 96a2355..de2bdfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ucast" -version = "0.2.0" +version = "0.1.1" description = "YouTube to Podcast converter" authors = ["Theta-Dev "] packages = [ diff --git a/ucast/__init__.py b/ucast/__init__.py index 7d8805f..93b1944 100644 --- a/ucast/__init__.py +++ b/ucast/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.2.0" +__version__ = "0.1.1" def template_context(request): diff --git a/ucast/queue.py b/ucast/queue.py index fbdf55e..5e56343 100644 --- a/ucast/queue.py +++ b/ucast/queue.py @@ -4,7 +4,6 @@ import rq_scheduler from django.conf import settings from rq import registry -from ucast.models import Video from ucast.service import util @@ -34,7 +33,8 @@ def get_worker(**kwargs) -> rq.Worker: def enqueue(f, *args, **kwargs) -> rq.job.Job: queue = get_queue() - return queue.enqueue(f, *args, **kwargs) + # return queue.enqueue(f, *args, **kwargs) + return queue.enqueue_call(f, args, kwargs) def get_statistics() -> dict: @@ -90,19 +90,3 @@ def get_statistics() -> dict: def get_failed_job_registry(): queue = get_queue() return registry.FailedJobRegistry(queue.name, queue.connection) - - -def get_downloading_videos(): - queue = get_queue() - videos = {} - - for job in queue.jobs: - if ( - job.func_name == "ucast.tasks.download.download_video" - and job.args - and isinstance(job.args[0], Video) - ): - video = job.args[0] - videos[video.id] = video - - return list(videos.values()) diff --git a/ucast/service/youtube.py b/ucast/service/youtube.py index 670cc46..1ae4479 100644 --- a/ucast/service/youtube.py +++ b/ucast/service/youtube.py @@ -125,19 +125,7 @@ def download_thumbnail(vinfo: VideoDetails, download_path: Path): def get_video_details(video_id: str) -> VideoDetails: - """ - Get the details of a YouTube video without downloading it. - - :param video_id: YouTube video ID - :return: VideoDetails - """ - cache = storage.Cache() - - ydl_params = { - "cachedir": str(cache.dir_ytdlp_cache), - } - - with YoutubeDL(ydl_params) as ydl: + with YoutubeDL() as ydl: info = ydl.extract_info(video_id, download=False) return VideoDetails.from_vinfo(info) diff --git a/ucast/tasks/download.py b/ucast/tasks/download.py index be14ddb..a91ec4d 100644 --- a/ucast/tasks/download.py +++ b/ucast/tasks/download.py @@ -10,13 +10,6 @@ from ucast.service import controller, cover, storage, util, videoutil, youtube def _load_scraped_video(vid: youtube.VideoScraped, channel: Channel): - # Use Redis to ensure the same video is not processed multiple times - redis = queue.get_redis_connection() - lock_key = f"ucast:lock_load_video:{vid.id}" - - if not redis.set(lock_key, "1", 120, nx=True): - return - # Create video object if it does not exist try: video = Video.objects.get(video_id=vid.id) @@ -25,7 +18,6 @@ def _load_scraped_video(vid: youtube.VideoScraped, channel: Channel): # Dont load active livestreams if details.is_currently_live: - redis.delete(lock_key) return slug = Video.get_new_slug( @@ -52,8 +44,6 @@ def _load_scraped_video(vid: youtube.VideoScraped, channel: Channel): ): queue.enqueue(download_video, video) - redis.delete(lock_key) - def download_video(video: Video): """ diff --git a/ucast/templates/bulma/base.html b/ucast/templates/bulma/base.html index c20531b..431b8ce 100644 --- a/ucast/templates/bulma/base.html +++ b/ucast/templates/bulma/base.html @@ -27,8 +27,8 @@