Skip to content

Commit

Permalink
fixed issue(#25) files are skipped when there is no banner, update im…
Browse files Browse the repository at this point in the history
…age format
  • Loading branch information
elvis972602 committed Aug 4, 2023
1 parent 69bfc75 commit 71fac22
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
9 changes: 0 additions & 9 deletions kemono/fetch.go
Expand Up @@ -169,12 +169,3 @@ func AddIndexToAttachments(attachments []File) []FileWithIndex {
}
return files
}

func isImage(ext string) bool {
switch ext {
case ".jpg", ".png", ".gif", ".webp", ".bmp", ".tiff", ".svg", ".ico", ".jpeg", ".jfif", ".jpe":
return true
default:
return false
}
}
3 changes: 2 additions & 1 deletion kemono/kemono.go
Expand Up @@ -258,7 +258,8 @@ func (k *Kemono) Start() {

// filter attachments
for i, post := range posts {
if k.Banner && post.File.Path != "" {
// download banner if banner is true or file is not image
if (k.Banner && post.File.Path != "") || !isImage(filepath.Ext(post.File.Name)) {
res := make([]File, len(post.Attachments)+1)
copy(res[1:], post.Attachments)
res[0] = post.File
Expand Down
10 changes: 10 additions & 0 deletions kemono/utils.go
@@ -0,0 +1,10 @@
package kemono

func isImage(ext string) bool {
switch ext {
case ".apng", ".avif", ".bmp", ".gif", ".ico", ".cur", ".jpg", ".jpeg", ".jfif", ".pjpeg", ".pjp", ".png", ".svg", ".tif", ".tiff", ".webp", ".jpe":
return true
default:
return false
}
}
2 changes: 1 addition & 1 deletion main/main.go
Expand Up @@ -494,7 +494,7 @@ func parasLink(link string) (s, service, userId, postId string) {
log.Fatal("invalid url")
}

pattern := `(?i)^(?:.*\.)?(kemono|coomer)\.party$`
pattern := `(?i)^(?:.*\.)?(kemono|coomer)\.(?:party|su)$`
re := regexp.MustCompile(pattern)

matchedSubstrings := re.FindStringSubmatch(u.Host)
Expand Down
2 changes: 1 addition & 1 deletion main/path.go
Expand Up @@ -119,7 +119,7 @@ func (t *TmplCache) Execute(typ string, config *PathConfig) string {

func getTyp(ext string) string {
switch ext {
case ".jpg", ".png", ".gif", ".webp", ".bmp", ".tiff", ".svg", ".ico", ".jpeg", ".jfif", ".jpe":
case ".apng", ".avif", ".bmp", ".gif", ".ico", ".cur", ".jpg", ".jpeg", ".jfif", ".pjpeg", ".pjp", ".png", ".svg", ".tif", ".tiff", ".webp", ".jpe":
return "image"
case ".mp4", ".webm", ".mkv", ".avi", ".mov", ".wmv", ".flv", ".f4v", ".m4v", ".rmvb", ".rm", ".3gp", ".dat", ".ts", ".mts", ".vob":
return "video"
Expand Down

0 comments on commit 71fac22

Please sign in to comment.