Skip to content

Commit

Permalink
Merge pull request #40 from zaanposni/39-try-redownload-of-pietsmiet-…
Browse files Browse the repository at this point in the history
…video-thumbnails-and-update-if-needed

39 try redownload of pietsmiet video thumbnails and update if needed
  • Loading branch information
zaanposni authored Feb 2, 2024
2 parents 91aec12 + c888825 commit 82173c7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
24 changes: 20 additions & 4 deletions src/dataimport/pietsmietdevideoimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,43 @@ async def stuff() -> asyncio.coroutine:
(:id ,:remoteId,:title, NULL , NULL ,:startDate,:imageUri,:href,:duration, now() , 'PietSmietDE', 'PSVideo');"""

UPDATE_STATEMENT = """
UPDATE ContentPiece SET href=:href, title=:title, duration=:duration WHERE id=:id;"""
UPDATE ContentPiece SET href=:href, title=:title, duration=:duration, imageUri=:imageUri WHERE id=:id;"""

console.log("Checking for existing entries...")
for content in data:
result = await db.fetch_all(
result = await db.fetch_one(
"SELECT * FROM ContentPiece WHERE remoteId = :remoteId AND importedFrom = 'PietSmietDE'",
values={"remoteId": content["remoteId"]},
)
if len(result) > 0:
if result:
console.log(
f"Found existing entry for {content['remoteId']}. Updating...",
style="bright_magenta",
)

newImageUri = result.imageUri
if result.imageUri is None and content["imageUri"] != None:
console.log(
f"Try redownloading thumbnail for {content['remoteId']}...",
style="bright_magenta",
)
try:
thumbnail = requests.get(content["imageUri"]).content
filename = f"{uuid4()}.jpg"
with open(f"/app/cdn/psde/{filename}", "wb") as f:
f.write(thumbnail)
newImageUri = f"/cdn/psde/{filename}"
except Exception as e:
console.log(f"Error downloading thumbnail: {e}", style="bold red")

await db.execute(
UPDATE_STATEMENT,
values={
"href": content["uri"],
"title": content["title"],
"duration": content["duration"],
"id": result[0]["id"],
"id": result.id,
"imageUri": newImageUri,
},
)

Expand Down
4 changes: 2 additions & 2 deletions src/psaggregator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/psaggregator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "psaggregator",
"version": "1.7.1",
"version": "1.7.2",
"scripts": {
"dev": "vite dev",
"build": "vite build",
Expand Down
30 changes: 6 additions & 24 deletions src/psaggregator/src/lib/components/Changelog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

<h1 class="mb-8 text-4xl font-bold">Version {version}</h1>

<div class="mb-4">
Vielen Dank für euer gutes Feedback und die vielen Vorschläge. Ich habe versucht, so viele wie möglich umzusetzen.
</div>

<div class="grow overflow-y-auto" id="changelog-contents">
<h2 class="mb-4 text-2xl font-bold">Bugfixes</h2>
<div>
<span>pietsmiet.de Import</span>
<span
>Ein einzelnes Video konnte aufgrund eines selten Fehlers letzte Woche nicht importiert werden. Diesen Fehler habe ich
behoben.</span>
</div>
<div>
<span>Instagram-Import</span>
<span
Expand All @@ -39,25 +41,5 @@
<span>Übersicht News-Seite</span>
<span>Auf mobilen Endgeräten hat die News-Seite nun ein Tabsystem bekommen, damit man nicht mehr so weit scrollen muss.</span>
</div>
<div>
<span>Mehr Details in /videos</span>
<span>Du kannst nun auf der Videos-Seite mehr Details ansehen. </span>
</div>
<div>
<span>Alte Uploadpläne</span>
<span>Du kannst nun alte Uploadpläne ansehen. Beachte, dass historische Daten noch nicht importiert wurden.</span>
</div>
<div>
<span>Uploadplan hochgeladene Videos</span>
<span>Im Uploadplan ist die Unterscheidung zwischen hochgeladenen und nicht hochgeladenen Videos nun deutlicher.</span>
</div>
<div>
<span>Datumswerte einstellbar</span>
<span>Auf der neuen "Einstellungen" Seite kannst du wählen, ob du absolute oder relative Datumswerte sehen willst.</span>
</div>
<div>
<span>Footer und Header überarbeitet</span>
<span>Der Footer und der Header wurden überarbeitet. Externe Links sind nun getrennt von internen Links.</span>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/psaggregator/src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function load() {
orderBy: {
startDate: "asc"
},
take: 5
take: 8
});

const twitchStatus = await prisma.twitchStatus.findFirst();
Expand All @@ -80,7 +80,7 @@ export async function load() {
orderBy: {
date: "desc"
},
take: 3
take: 5
});

const instagramPosts = await prisma.information.findMany({
Expand Down

0 comments on commit 82173c7

Please sign in to comment.