From ad939f0c7ea5a529de77588c76423dea0f7ba69d Mon Sep 17 00:00:00 2001 From: zaanposni Date: Sun, 8 Dec 2024 11:40:32 +0100 Subject: [PATCH 1/6] ignore reddit and upcoming streams for updatenotification on start page --- src/psaggregator/src/routes/+page.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/psaggregator/src/routes/+page.svelte b/src/psaggregator/src/routes/+page.svelte index 54ac575..19670e3 100644 --- a/src/psaggregator/src/routes/+page.svelte +++ b/src/psaggregator/src/routes/+page.svelte @@ -29,9 +29,7 @@ ...(data.youtubeCommunityPosts?.map((entry: Information) => moment(entry.date)) ?? []), ...(data.instagramPosts?.map((entry: Information) => moment(entry.date)) ?? []), ...(data.twitterPosts?.map((entry: Information) => moment(entry.date)) ?? []), - ...(data.redditPosts?.map((entry: RedditPost) => moment(entry.date)) ?? []), ...(data.videos?.map((entry: ContentPiece) => moment(entry.startDate)) ?? []), - ...(data.upcomingStreams?.map((entry: ScheduledContentPiece) => moment(entry.startDate)) ?? []), moment((data.twitchStatus as TwitchStatus)?.startedAt ?? 0) ]; From 6601c8db86b7ef659d292da21925a347c135270c Mon Sep 17 00:00:00 2001 From: zaanposni Date: Sun, 8 Dec 2024 11:44:37 +0100 Subject: [PATCH 2/6] fix hour/minute display for psvideo --- src/psaggregator/src/lib/components/PSVideo.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/psaggregator/src/lib/components/PSVideo.svelte b/src/psaggregator/src/lib/components/PSVideo.svelte index 7138fbc..bac3487 100644 --- a/src/psaggregator/src/lib/components/PSVideo.svelte +++ b/src/psaggregator/src/lib/components/PSVideo.svelte @@ -12,7 +12,8 @@ let classes = ""; export { classes as class }; - $: humanReadableMinutes = video.duration ? Math.floor(video.duration / 60) : null; + $: humanReadableHours = video.duration ? Math.floor(video.duration / 3600) : null; + $: humanReadableMinutes = video.duration ? Math.floor((video.duration % 3600) / 60) : null; $: humanReadableSeconds = video.duration ? video.duration % 60 : null; @@ -54,7 +55,9 @@
{#if humanReadableMinutes !== null && humanReadableSeconds !== null} {("00" + humanReadableMinutes).slice(-2)}:{("00" + humanReadableSeconds).slice(-2)} + >{#if humanReadableHours}{("00" + humanReadableHours).slice(-2)}:{/if}{("00" + humanReadableMinutes).slice(-2)}:{( + "00" + humanReadableSeconds + ).slice(-2)} {/if} From 128fa6c6ff72cb006c98bdddbf4d644b5cf055ed Mon Sep 17 00:00:00 2001 From: zaanposni Date: Sun, 8 Dec 2024 11:57:58 +0100 Subject: [PATCH 3/6] also set youtube link in uploadplan if available --- src/dataimport/youtube_video_linker.py | 48 +++++++++++++------ .../src/lib/components/UploadPlanEntry.svelte | 3 +- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/dataimport/youtube_video_linker.py b/src/dataimport/youtube_video_linker.py index 34b3aeb..a296f5a 100644 --- a/src/dataimport/youtube_video_linker.py +++ b/src/dataimport/youtube_video_linker.py @@ -25,7 +25,8 @@ collection_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&maxResults=50&channelId={}&type=video&key={}" youtube_url_template = "https://youtu.be/{}" -UPDATE_STATEMENT = "UPDATE ContentPiece SET description = :description, secondaryHref = :secondaryHref WHERE id = :id" +UPDATE_STATEMENT_CONTENTPIECE = "UPDATE ContentPiece SET description = :description, secondaryHref = :secondaryHref WHERE id = :id AND type = 'PSVideo'" +UPDATE_STATEMENT_PLAN = "UPDATE ScheduledContentPiece SET description = :description, secondaryHref = :secondaryHref WHERE remoteId = :remoteId AND type = 'PSVideo'" def replace_emojis_with_question_mark(text): @@ -74,27 +75,44 @@ async def youtube(): "upperBoundary": one_week_after.strftime("%Y-%m-%d %H:%M:%S"), } + description = video["snippet"]["description"] + secondaryHref = youtube_url_template.format(video["id"]["videoId"]) + result = await db.fetch_one(query=query, values=values) if not result: console.log(f"Could not find a matching video for '{title}'") continue - if result.description is not None or result.secondaryHref is not None: - console.log( - f"ContentPiece {result.id} already has a description or secondaryHref" - ) - continue - description = video["snippet"]["description"] - secondaryHref = youtube_url_template.format(video["id"]["videoId"]) + if result.description is None and result.secondaryHref is None: + values = { + "id": result.id, + "description": description, + "secondaryHref": secondaryHref, + } - values = { - "id": result.id, - "description": description, - "secondaryHref": secondaryHref, - } + console.log( + f"Updating ContentPiece {result.id} with secondaryHref {secondaryHref}" + ) + await db.execute(query=UPDATE_STATEMENT_CONTENTPIECE, values=values) + else: + console.log( + f"ContentPiece {result.id} already has a description and secondaryHref. Skipping update" + ) - console.log(f"Updating {result.id} with secondaryHref {secondaryHref}") - await db.execute(query=UPDATE_STATEMENT, values=values) + if result.remoteId: + values = { + "remoteId": result.remoteId, + "description": description, + "secondaryHref": secondaryHref, + } + console.log( + f"Updating ScheduledContentPiece {result.remoteId} with secondaryHref {secondaryHref}" + ) + await db.execute(query=UPDATE_STATEMENT_PLAN, values=values) + else: + console.log( + f"ContentPiece {result.id} does not have a remoteId. Skipping ScheduledContentPiece update" + ) await db.disconnect() console.log("Done") diff --git a/src/psaggregator/src/lib/components/UploadPlanEntry.svelte b/src/psaggregator/src/lib/components/UploadPlanEntry.svelte index 0917783..914e637 100644 --- a/src/psaggregator/src/lib/components/UploadPlanEntry.svelte +++ b/src/psaggregator/src/lib/components/UploadPlanEntry.svelte @@ -5,6 +5,7 @@ import Sparkle from "./Sparkle.svelte"; import * as Card from "$lib/components/ui/card"; import { Button } from "./ui/button"; + import { LINK_YOUTUBE } from "../../config/config"; export let entry: ScheduledContentPiece; @@ -34,7 +35,7 @@
{/if} {#if entry.href} -