Skip to content

Commit

Permalink
Added proper filter so that fetchNewVideos does not yield muxed videos.
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Aug 18, 2023
1 parent 25095b0 commit 7fe9d91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Downloader.ts
@@ -1,5 +1,5 @@
import { MultiProgressBars, UpdateOptions } from "multi-progress-bars";
import { VideoState, Video } from "./lib/Video.js";
import { Video } from "./lib/Video.js";

import { settings, args } from "./lib/helpers.js";
import { MyPlexAccount } from "@ctrl/plex";
Expand Down Expand Up @@ -100,7 +100,7 @@ const processVideo = async (fTitle: string, video: Video, retries = 0) => {
if (settings.extras.downloadArtwork) await video.downloadArtwork();

switch (await video.getState()) {
case VideoState.Missing: {
case Video.State.Missing: {
mpb?.addTask(fTitle, {
type: "percentage",
message: "Waiting on delivery cdn...",
Expand Down Expand Up @@ -145,7 +145,7 @@ const processVideo = async (fTitle: string, video: Video, retries = 0) => {
delete summaryStats[fTitle];
}
// eslint-disable-next-line no-fallthrough
case VideoState.Partial: {
case Video.State.Partial: {
log(fTitle, {
percentage: 0.99,
message: "Muxing ffmpeg metadata...",
Expand All @@ -165,7 +165,7 @@ const processVideo = async (fTitle: string, video: Video, retries = 0) => {
}
}
// eslint-disable-next-line no-fallthrough
case VideoState.Muxed: {
case Video.State.Muxed: {
completedVideos++;
updateSummaryBar();
mpb?.done(fTitle);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Subscription.ts
Expand Up @@ -151,7 +151,9 @@ export default class Subscription {
if (settings.floatplane.videosToSearch === 0) return;
let videosSearched = 0;
for await (const blogPost of fApi.creator.blogPostsIterable(this.creatorId, { hasVideo: true })) {
for await (const video of this.matchChannel(blogPost)) yield video;
for await (const video of this.matchChannel(blogPost)) {
if ((await video.getState()) !== Video.State.Muxed) yield video;
}

// Stop searching if we have looked through videosToSearch
if (videosSearched++ >= settings.floatplane.videosToSearch) break;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Video.ts
Expand Up @@ -31,7 +31,7 @@ const fileExists = async (path: string): Promise<boolean> => {
}
};

export enum VideoState {
enum VideoState {
Missing,
Partial,
Muxed,
Expand All @@ -57,6 +57,8 @@ export class Video {
public title: BlogPost["title"];
public channelTitle: string;

public static State = VideoState;

private static OriginSelector = 0;
private originSelector = Video.OriginSelector;

Expand Down

0 comments on commit 7fe9d91

Please sign in to comment.