Skip to content

Commit

Permalink
addresses #193, #182
Browse files Browse the repository at this point in the history
  • Loading branch information
5rahim committed Jan 4, 2025
1 parent 94124d3 commit d24afde
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file.

## v2.6.1

- ⚡️ Anime library: Filtering by year now takes into account the season year
- ⚡️ Torrent streaming: Custom stream URL address setting #182
- 🦺 Scanner: Fixed duplicated files due to incorrect path comparison
- 🦺 Use AniList season year instead of start year for media cards #193
- 🏗️ Issue recorder: Increase data cap limit

## v2.6.0
Expand Down
27 changes: 27 additions & 0 deletions codegen/generated/public_structs.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@
"public": true,
"comments": []
},
{
"name": "SeasonYear",
"jsonName": "seasonYear",
"goType": "int",
"typescriptType": "number",
"required": false,
"public": true,
"comments": []
},
{
"name": "BannerImage",
"jsonName": "bannerImage",
Expand Down Expand Up @@ -321,6 +330,15 @@
"public": true,
"comments": []
},
{
"name": "SeasonYear",
"jsonName": "seasonYear",
"goType": "int",
"typescriptType": "number",
"required": false,
"public": true,
"comments": []
},
{
"name": "Type",
"jsonName": "type",
Expand Down Expand Up @@ -28005,6 +28023,15 @@
"required": true,
"public": true,
"comments": []
},
{
"name": "StreamUrlAddress",
"jsonName": "streamUrlAddress",
"goType": "string",
"typescriptType": "string",
"required": true,
"public": true,
"comments": []
}
],
"comments": [],
Expand Down
26 changes: 26 additions & 0 deletions internal/api/anilist/client_gen.go

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

1 change: 1 addition & 0 deletions internal/api/anilist/media_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func (m *CompleteAnime) ToBaseAnime() *BaseAnime {
Synonyms: m.GetSynonyms(),
BannerImage: m.GetBannerImage(),
Season: m.GetSeason(),
SeasonYear: m.GetSeasonYear(),
Type: m.GetType(),
IsAdult: m.GetIsAdult(),
CountryOfOrigin: m.GetCountryOfOrigin(),
Expand Down
2 changes: 2 additions & 0 deletions internal/api/anilist/queries/anime.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ fragment baseAnime on Media {
season
type
format
seasonYear
bannerImage
episodes
synonyms
Expand Down Expand Up @@ -324,6 +325,7 @@ fragment completeAnime on Media {
siteUrl
status(version: 2)
season
seasonYear
type
format
bannerImage
Expand Down
1 change: 1 addition & 0 deletions internal/core/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ func (a *App) InitOrRefreshTorrentstreamSettings() {
StreamingServerHost: "0.0.0.0",
StreamingServerPort: 43214,
IncludeInLibrary: false,
StreamUrlAddress: "",
})
if err != nil {
a.Logger.Error().Err(err).Msg("app: Failed to initialize mediastream module")
Expand Down
2 changes: 2 additions & 0 deletions internal/database/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ type TorrentstreamSettings struct {
StreamingServerPort int `gorm:"column:streaming_server_port" json:"streamingServerPort"` // UNUSED, LEGACY
//FallbackToTorrentStreamingView bool `gorm:"column:fallback_to_torrent_streaming_view" json:"fallbackToTorrentStreamingView"` // DEPRECATED
IncludeInLibrary bool `gorm:"column:include_in_library" json:"includeInLibrary"`
// v2.6+
StreamUrlAddress string `gorm:"column:stream_url_address" json:"streamUrlAddress"`
}

type TorrentstreamHistory struct {
Expand Down
9 changes: 8 additions & 1 deletion internal/torrentstream/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,14 @@ func (c *Client) GetStreamingUrl() string {
return ""
}
address := fmt.Sprintf("%s:%d", c.repository.settings.MustGet().Host, c.repository.settings.MustGet().Port)
return fmt.Sprintf("http://%s/api/v1/torrentstream/stream/%s", address, url.PathEscape(c.currentFile.MustGet().DisplayPath()))
if c.repository.settings.MustGet().StreamUrlAddress != "" {
address = c.repository.settings.MustGet().StreamUrlAddress
}
_url := fmt.Sprintf("http://%s/api/v1/torrentstream/stream/%s", address, url.PathEscape(c.currentFile.MustGet().DisplayPath()))
if strings.HasPrefix(_url, "http://http") {
_url = strings.Replace(_url, "http://http", "http", 1)
}
return _url
}

func (c *Client) AddTorrent(id string) (*torrent.Torrent, error) {
Expand Down
2 changes: 2 additions & 0 deletions seanime-web/src/api/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ export type AL_BaseAnime = {
season?: AL_MediaSeason
type?: AL_MediaType
format?: AL_MediaFormat
seasonYear?: number
bannerImage?: string
episodes?: number
synonyms?: Array<string>
Expand Down Expand Up @@ -2872,6 +2873,7 @@ export type Models_TorrentstreamSettings = {
*/
streamingServerPort: number
includeInLibrary: boolean
streamUrlAddress: string
id: number
createdAt?: string
updatedAt?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ export function GlobalSearch() {
<p className="text-sm leading-6 text-[--muted]">
{activeOption.format}{activeOption.season
? ` - ${capitalize(activeOption.season)} `
: " - "}{activeOption.startDate?.year
? new Intl.DateTimeFormat("en-US", { year: "numeric" })
.format(new Date(activeOption.startDate?.year || 0,
activeOption.startDate?.month || 0))
: " - "}{activeOption.seasonYear
? activeOption.seasonYear
: "-"}
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function MediaEntryCard<T extends "anime" | "manga">(props: MediaEntryCar

<MediaEntryCardHoverPopupTitleSection
title={media.title?.userPreferred || ""}
year={media.startDate?.year}
year={(media as AL_BaseAnime).seasonYear ?? media.startDate?.year}
season={media.season}
format={media.format}
link={link}
Expand Down Expand Up @@ -286,7 +286,7 @@ export function MediaEntryCard<T extends "anime" | "manga">(props: MediaEntryCar

<MediaEntryCardTitleSection
title={media.title?.userPreferred || ""}
year={media.startDate?.year}
year={(media as AL_BaseAnime).seasonYear ?? media.startDate?.year}
season={media.season}
format={media.format}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const torrentstreamSchema = defineSchema(({ z }) => z.object({
torrentClientPort: z.number(),
preferredResolution: z.string(),
includeInLibrary: z.boolean(),
streamUrlAddress: z.string().optional().default(""),
}))


Expand Down Expand Up @@ -68,6 +69,7 @@ export function TorrentstreamSettings(props: TorrentstreamSettingsProps) {
torrentClientPort: settings.torrentClientPort,
preferredResolution: settings.preferredResolution || "-",
includeInLibrary: settings.includeInLibrary,
streamUrlAddress: settings.streamUrlAddress || "",
}}
stackClass="space-y-6"
>
Expand Down Expand Up @@ -160,6 +162,15 @@ export function TorrentstreamSettings(props: TorrentstreamSettingsProps) {
label="Disable IPv6"
/>

<Separator />

<Field.Text
name="streamUrlAddress"
label="Stream URL address"
placeholder="e.g. {host}:{port}"
help="Leave empty for default. The URL to use for streaming."
/>


<div className="flex w-full items-center">
<SettingsSubmitButton isPending={isPending} />
Expand Down
6 changes: 4 additions & 2 deletions seanime-web/src/lib/helpers/filtering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export function filterListEntries<T extends AL_MangaCollection_MediaListCollecti
if (!!arr && !!params.status) arr = arr.filter(n => n.media?.status === params.status)

// Filter by year
if (!!arr && !!params.year) arr = arr.filter(n => n.media?.startDate?.year === Number(params.year))
if (!!arr && !!params.year) arr = arr.filter(n => (n.media as AL_BaseAnime)?.seasonYear ?
((n.media as AL_BaseAnime)?.seasonYear === Number(params.year) || n.media?.startDate?.year === Number(params.year))
: n.media?.startDate?.year === Number(params.year))

// Filter by genre
if (!!arr && !!params.genre?.length) {
Expand Down Expand Up @@ -193,7 +195,7 @@ export function filterCollectionEntries<T extends Anime_LibraryCollectionEntry[]
if (!!arr && !!params.status) arr = arr.filter(n => n.media?.status === params.status)

// Filter by year
if (!!arr && !!params.year) arr = arr.filter(n => n.media?.startDate?.year === Number(params.year))
if (!!arr && !!params.year) arr = arr.filter(n => n.media?.seasonYear === Number(params.year) || n.media?.startDate?.year === Number(params.year))

// Filter by genre
if (!!arr && !!params.genre?.length) {
Expand Down

0 comments on commit d24afde

Please sign in to comment.