Skip to content

Commit

Permalink
CoomerSu | Fix posts without attachments not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNetsky committed Sep 28, 2024
1 parent 62b01a5 commit 9dafea3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/CoomerSu/CoomerSu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const CSU_DOMAIN = 'https://coomer.su'
const CSU_API_DOMAIN = CSU_DOMAIN + '/api/v1'

export const CoomerSuInfo: SourceInfo = {
version: '1.0.0',
version: '1.0.1',
name: 'CoomerSu',
icon: 'icon.png',
author: 'Netsky',
Expand Down
22 changes: 14 additions & 8 deletions src/CoomerSu/CoomerSuParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {

import { Post } from './interface/Post'

export const parseMangaDetails = async (source: any, data: Post[], mangaId: string): Promise<SourceManga> => {
export const parseMangaDetails = async (source: any, posts: Post[], mangaId: string): Promise<SourceManga> => {

const post = data[0] as Post
const post = posts[0] as Post
const creatorData = await fetchCreatorData(source, post.user, post.service)

return App.createSourceManga({
Expand All @@ -38,17 +38,18 @@ export const parseMangaDetails = async (source: any, data: Post[], mangaId: stri
})
}

export const parseChapters = async (source: any, data: Post[], mangaId: string): Promise<Chapter[]> => {
export const parseChapters = async (source: any, posts: Post[], mangaId: string): Promise<Chapter[]> => {
const chapters: Chapter[] = []
let sortingIndex = 0

for (const post of data) {
for (const post of posts) {
const title = `Posted ${daysAgo(post.published)} days ago`
const chapterId = post.id
const date: Date = post.published

const filteredAttachments = post.attachments.filter(x => !x.name.includes('.mp4'))
if (filteredAttachments.length === 0) {
const filterAttachments = post.attachments.filter(x => !x.name.includes('.mp4'))
const filteredFile = post?.file?.name?.includes('.mp4')
if (filterAttachments.length === 0 && filteredFile) {
continue
}

Expand Down Expand Up @@ -77,10 +78,15 @@ export const parseChapters = async (source: any, data: Post[], mangaId: string):
})
}

export const parseChapterDetails = (source: any, data: Post, mangaId: string, chapterId: string): ChapterDetails => {
export const parseChapterDetails = (source: any, post: Post, mangaId: string, chapterId: string): ChapterDetails => {
const pages: string[] = []

for (const attachment of data.attachments) {
// If the file is not an MP4, push to pages
if (!post.file.name.includes('.mp4')) {
pages.push(source.baseURL + post.file.path)
}

for (const attachment of post.attachments) {
if (!attachment.path) continue
if (attachment.name.endsWith('.mp4')) continue

Expand Down
5 changes: 4 additions & 1 deletion src/CoomerSu/interface/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export interface Post {
added: Date;
published: Date;
edited: null;
file: any;
file: {
name: string;
path: string;
};
attachments: Attachment[];
poll: null;
captions: null;
Expand Down

0 comments on commit 9dafea3

Please sign in to comment.