Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
fix: OBS scene on media pause; WT sort order; fetch subtitles only wh…
Browse files Browse the repository at this point in the history
…en enabled
  • Loading branch information
sircharlo committed Jun 16, 2024
1 parent 8ac6c25 commit d430399
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 23 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"localstorage",
"meps",
"mepslangs",
"Multimeps",
"mwbr",
"myapp",
"nodir",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mmm-v2",
"version": "24.6.1",
"version": "24.6.2",
"description": "A cross platform app to download and present media (pictures and videos) for congregation meetings of Jehovah’s Witnesses in any language. Features include recurring and custom media management, congregation sync, and media presentation tools for hybrid, in-person or fully remote Zoom meetings.",
"productName": "Meeting Media Manager v2",
"author": "Olivier Savignac",
Expand Down
52 changes: 36 additions & 16 deletions src/helpers/jw-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ const fetchMedia = async () => {
);
const route = useRoute();
const fetchErrors = {} as Record<string, boolean>;
lookupPeriod.value.forEach((day) => {
day.loading = true;
});
for (const day of lookupPeriod.value.filter((day) => day.meeting)) {
if (
!currentCongregation.value ||
!['/media-calendar', '/setup-wizard'].includes(route.fullPath)
)
break;
const dayDate = day.date;
day.loading = true;
// day.loading = true;
let fetchResult = null;
if (day.meeting === 'we') {
fetchResult = await getWeMedia(dayDate);
Expand Down Expand Up @@ -294,9 +297,11 @@ const getDocumentMultimediaItems = (source: MultimediaItemsFetcher) => {
// let select = 'SELECT Multimedia.DocumentId, Multimedia.MultimediaId, ';
const select = 'SELECT * ';
let from = 'FROM Multimedia ';
if (mmTable === 'DocumentMultimedia')
if (mmTable === 'DocumentMultimedia') {
from +=
'INNER JOIN DocumentMultimedia ON DocumentMultimedia.MultimediaId = Multimedia.MultimediaId ';
from += `INNER JOIN DocumentParagraph ON ${mmTable}.BeginParagraphOrdinal = DocumentParagraph.ParagraphIndex `;
}
from += `INNER JOIN Document ON ${mmTable}.DocumentId = Document.DocumentId `;

let where = ` WHERE ${
Expand Down Expand Up @@ -324,7 +329,7 @@ const getDocumentMultimediaItems = (source: MultimediaItemsFetcher) => {
}

const groupAndSort = ParagraphColumnsExist
? ` GROUP BY Multimedia.MultimediaId ORDER BY ${mmTable}.BeginParagraphOrdinal`
? ' GROUP BY Multimedia.MultimediaId ORDER BY DocumentParagraph.BeginPosition'
: '';

if (targetParNrExists && ParagraphColumnsExist) {
Expand Down Expand Up @@ -601,16 +606,19 @@ const getWeMedia = async (lookupDate: Date) => {
}
const videos = executeQuery(
db,
`SELECT DocumentMultimedia.MultimediaId, DocumentMultimedia.DocumentId, MepsDocumentId, CategoryType, KeySymbol, Track, IssueTagNumber, MimeType, BeginParagraphOrdinal, TargetParagraphNumberLabel
`SELECT *
FROM DocumentMultimedia
INNER JOIN Multimedia
ON DocumentMultimedia.MultimediaId = Multimedia.MultimediaId
INNER JOIN DocumentParagraph
ON DocumentMultimedia.BeginParagraphOrdinal = DocumentParagraph.ParagraphIndex
LEFT JOIN Question
ON Question.DocumentId = DocumentMultimedia.DocumentId
AND Question.TargetParagraphOrdinal = DocumentMultimedia.BeginParagraphOrdinal
WHERE DocumentMultimedia.DocumentId = ${docId}
AND CategoryType = -1
GROUP BY DocumentMultimedia.MultimediaId`,
GROUP BY DocumentMultimedia.MultimediaId
ORDER BY DocumentParagraph.BeginPosition`,
) as MultimediaItem[];
const videosInParagraphs = videos.filter(
(video) => !!video.TargetParagraphNumberLabel,
Expand All @@ -622,10 +630,12 @@ const getWeMedia = async (lookupDate: Date) => {
const media = (
executeQuery(
db,
`SELECT DocumentMultimedia.MultimediaId, DocumentMultimedia.DocumentId, *
`SELECT *
FROM DocumentMultimedia
INNER JOIN Multimedia
ON DocumentMultimedia.MultimediaId = Multimedia.MultimediaId
INNER JOIN DocumentParagraph
ON DocumentMultimedia.BeginParagraphOrdinal = DocumentParagraph.ParagraphIndex
LEFT JOIN Question
ON Question.DocumentId = DocumentMultimedia.DocumentId
AND Question.TargetParagraphOrdinal = DocumentMultimedia.BeginParagraphOrdinal
Expand All @@ -634,7 +644,7 @@ const getWeMedia = async (lookupDate: Date) => {
AND CategoryType <> -1
AND (KeySymbol != '${currentSongbook.value.pub}' OR KeySymbol IS NULL)
GROUP BY DocumentMultimedia.MultimediaId
ORDER BY BeginParagraphOrdinal`, // pictures
ORDER BY DocumentParagraph.BeginPosition`, // pictures
) as MultimediaItem[]
)
.map((multimediaItem) =>
Expand Down Expand Up @@ -717,14 +727,20 @@ const getWeMedia = async (lookupDate: Date) => {
console.error(e);
songLangs = songs.map(() => getSettingValue('lang') as string);
}
const mergedSongs = songs.map((song, index) => ({
...song,
...(songLangs[index] ? { LangOverride: songLangs[index] } : {}),
}));

const allMedia = finalMedia
.concat(mergedSongs)
.sort((a, b) => a.BeginParagraphOrdinal - b.BeginParagraphOrdinal);
const mergedSongs = songs
.map((song, index) => ({
...song,
...(songLangs[index] ? { LangOverride: songLangs[index] } : {}),
}))
.sort(
(a, b) =>
(a.BeginParagraphOrdinal ?? 0) - (b.BeginParagraphOrdinal ?? 0),
);
const allMedia = finalMedia;
if (mergedSongs.length > 0) {
allMedia.unshift(mergedSongs[0]);
if (mergedSongs.length > 1) allMedia.push(mergedSongs[1]);
}

const multimediaMepsLangs = getMultimediaMepsLangs({ db, docId });
for (const media of allMedia) {
Expand Down Expand Up @@ -1067,7 +1083,11 @@ const downloadMissingMedia = async (publication: PublicationFetcher) => {
})) as DownloadedFile;

const jwMediaInfo = await getJwMediaInfo(publication);
for (const itemUrl of [jwMediaInfo.subtitles, jwMediaInfo.thumbnail]) {
const { currentSettings } = storeToRefs(useCurrentStateStore());
for (const itemUrl of [
currentSettings.value.enableSubtitles ? jwMediaInfo.subtitles : undefined,
jwMediaInfo.thumbnail,
].filter(Boolean)) {
if (!itemUrl) continue;
const itemFilename =
path.basename(bestItem.file.url).split('.')[0] + path.extname(itemUrl);
Expand Down
16 changes: 10 additions & 6 deletions src/pages/MediaCalendarPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
</template>
{{ $t('noMedia') }}
</q-banner>

<template
:key="media.uniqueId"
v-else
Expand Down Expand Up @@ -394,7 +393,8 @@
icon="mdi-pause"
round
v-else-if="
mediaPlayer.action === 'play' || !mediaPlayer.action
media.isVideo &&
(mediaPlayer.action === 'play' || !mediaPlayer.action)
"
/>
<!-- </transition> -->
Expand Down Expand Up @@ -633,6 +633,7 @@ const {
currentSettings,
getDatedAdditionalMediaDirectory,
lookupPeriod,
mediaPaused,
mediaPlayer,
mediaPlaying,
selectedDate,
Expand Down Expand Up @@ -796,10 +797,13 @@ dragAndDrop({
values: sortableMediaItems,
});
watch(mediaPlaying, (newValue) => {
setObsScene(!newValue ? 'camera' : 'media');
updateConfig(mediaList.value, { disabled: !!newValue });
});
watch(
() => [mediaPlaying.value, mediaPaused.value],
([newMediaPlaying, newMediaPaused]) => {
setObsScene(!newMediaPlaying || newMediaPaused ? 'camera' : 'media');
updateConfig(mediaList.value, { disabled: !!newMediaPlaying });
},
);
const fetchMediaFromCalendar = async () => {
const fetchResult = await fetchMedia();
Expand Down
5 changes: 5 additions & 0 deletions src/stores/current-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export const useCurrentStateStore = defineStore('current-state', {
dateString,
);
},
mediaPaused(state) {
return (
state.mediaPlayer.url !== '' && state.mediaPlayer.action === 'pause'
);
},
mediaPlaying(state) {
return state.mediaPlayer.url !== '';
},
Expand Down
1 change: 1 addition & 0 deletions src/types/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface JwPlaylistItem {
export interface MultimediaItem {
AlternativeLanguage?: string;
BeginParagraphOrdinal: number;
BeginPosition?: number;
Caption: string;
CaptionContent?: null | string;
CaptionRich?: null | string;
Expand Down

0 comments on commit d430399

Please sign in to comment.