Anime episodes stored under a different table
This commit is contained in:
parent
29842b3ccc
commit
8037edcb67
@ -1,21 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/twist"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
var rateLimiter = time.NewTicker(500 * time.Millisecond)
|
||||
|
||||
func main() {
|
||||
// Replace this with ID list from twist.moe later
|
||||
animeIDs := []string{
|
||||
"13274",
|
||||
"10902",
|
||||
}
|
||||
currentAnime, err := arn.FilterAnime(func(anime *arn.Anime) bool {
|
||||
return anime.Status == "current"
|
||||
})
|
||||
arn.PanicOnError(err)
|
||||
|
||||
for _, animeID := range animeIDs {
|
||||
color.Yellow("Refreshing twist.moe links for %d anime", len(currentAnime))
|
||||
|
||||
for count, anime := range currentAnime {
|
||||
// Wait for rate limiter
|
||||
<-rateLimiter.C
|
||||
|
||||
// anime, animeErr := arn.GetAnime(animeID)
|
||||
|
||||
// if animeErr != nil {
|
||||
// color.Red("Error fetching anime from the database with ID %s: %v", animeID, animeErr)
|
||||
// continue
|
||||
// }
|
||||
animeID := anime.ID
|
||||
|
||||
// Log
|
||||
fmt.Fprintf(os.Stdout, "[%d / %d] ", count+1, len(currentAnime))
|
||||
|
||||
// Get twist.moe feed
|
||||
feed, err := twist.GetFeedByKitsuID(animeID)
|
||||
|
||||
if err != nil {
|
||||
@ -30,6 +53,22 @@ func main() {
|
||||
return episodes[a].Number < episodes[b].Number
|
||||
})
|
||||
|
||||
arn.PrettyPrint(episodes)
|
||||
for _, episode := range episodes {
|
||||
arnEpisode := anime.EpisodeByNumber(episode.Number)
|
||||
|
||||
if arnEpisode == nil {
|
||||
color.Red("Anime %s Episode %d not found", anime.ID, episode.Number)
|
||||
continue
|
||||
}
|
||||
|
||||
if arnEpisode.Links == nil {
|
||||
arnEpisode.Links = map[string]string{}
|
||||
}
|
||||
|
||||
arnEpisode.Links["twist.moe"] = strings.Replace(episode.Link, "https://test.twist.moe/", "https://twist.moe/", 1)
|
||||
}
|
||||
|
||||
arn.PanicOnError(anime.Episodes().Save())
|
||||
color.Green("Found %d episodes for anime %s", len(episodes), animeID)
|
||||
}
|
||||
}
|
||||
|
4
main.go
4
main.go
@ -71,8 +71,8 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/explore", explore.Get)
|
||||
app.Ajax("/forum", forums.Get)
|
||||
app.Ajax("/forum/:tag", forum.Get)
|
||||
app.Ajax("/threads/:id", threads.Get)
|
||||
app.Ajax("/posts/:id", posts.Get)
|
||||
app.Ajax("/thread/:id", threads.Get)
|
||||
app.Ajax("/post/:id", posts.Get)
|
||||
app.Ajax("/tracks/:id", tracks.Get)
|
||||
app.Ajax("/new/thread", newthread.Get)
|
||||
app.Ajax("/new/soundtrack", newsoundtrack.Get)
|
||||
|
@ -6,7 +6,7 @@ component ThreadLink(thread *arn.Thread)
|
||||
.thread-content
|
||||
if thread.Sticky != 0
|
||||
Icon("thumb-tack")
|
||||
a.thread-link-title.ajax(href="/threads/" + thread.ID)= thread.Title
|
||||
a.thread-link-title.ajax(href="/thread/" + thread.ID)= thread.Title
|
||||
.spacer
|
||||
.thread-reply-count= len(thread.Posts)
|
||||
.thread-icons
|
||||
|
@ -31,12 +31,12 @@ func Get(ctx *aero.Context) string {
|
||||
|
||||
episodesReversed := false
|
||||
|
||||
if len(anime.Episodes) > maxEpisodes {
|
||||
if len(anime.Episodes().Items) > maxEpisodes {
|
||||
episodesReversed = true
|
||||
anime.Episodes = anime.Episodes[len(anime.Episodes)-maxEpisodesLongSeries:]
|
||||
anime.Episodes().Items = anime.Episodes().Items[len(anime.Episodes().Items)-maxEpisodesLongSeries:]
|
||||
|
||||
for i, j := 0, len(anime.Episodes)-1; i < j; i, j = i+1, j-1 {
|
||||
anime.Episodes[i], anime.Episodes[j] = anime.Episodes[j], anime.Episodes[i]
|
||||
for i, j := 0, len(anime.Episodes().Items)-1; i < j; i, j = i+1, j-1 {
|
||||
anime.Episodes().Items[i], anime.Episodes().Items[j] = anime.Episodes().Items[j], anime.Episodes().Items[i]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,20 +147,23 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis
|
||||
each track in tracks
|
||||
SoundTrack(track)
|
||||
|
||||
if len(anime.Episodes) > 0
|
||||
if len(anime.Episodes().Items) > 0
|
||||
if episodesReversed
|
||||
h3.anime-section-name Latest episodes
|
||||
else
|
||||
h3.anime-section-name Episodes
|
||||
table.episodes
|
||||
tbody
|
||||
each episode in anime.Episodes
|
||||
each episode in anime.Episodes().Items
|
||||
tr.episode
|
||||
td.episode-number= episode.Number
|
||||
td.episode-title= episode.Title.Japanese
|
||||
td.episode-actions
|
||||
a(href="https://translate.google.com/#ja/en/" + episode.Title.Japanese, target="_blank", rel="noopener")
|
||||
RawIcon("google")
|
||||
for name, link := range episode.Links
|
||||
a(href=link, target="_blank", rel="noopener", title="Watch episode " + toString(episode.Number) + " on " + name)
|
||||
RawIcon("eye")
|
||||
//- a(href="https://translate.google.com/#ja/en/" + episode.Title.Japanese, target="_blank", rel="noopener")
|
||||
//- RawIcon("google")
|
||||
td.episode-airing-date-start.utc-airing-date(data-start-date=episode.AiringDate.Start, data-end-date=episode.AiringDate.End, data-episode-number=episode.Number)= episode.AiringDate.StartDateHuman()
|
||||
|
||||
//- h3.anime-section-name Reviews
|
||||
|
@ -36,26 +36,25 @@ component AnimeLists(animeLists map[string]*arn.AnimeList, viewUser *arn.User, u
|
||||
//- AnimeList(animeList, user)
|
||||
|
||||
component AnimeList(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User)
|
||||
table.anime-list
|
||||
thead
|
||||
tr
|
||||
th.anime-list-item-name Anime
|
||||
th.anime-list-item-airing-date Airing
|
||||
th.anime-list-item-episodes Episodes
|
||||
th.anime-list-item-rating Overall
|
||||
//- th.anime-list-item-rating Story
|
||||
//- th.anime-list-item-rating Visuals
|
||||
//- th.anime-list-item-rating Soundtrack
|
||||
if user != nil
|
||||
th.anime-list-item-actions Actions
|
||||
tbody
|
||||
table
|
||||
tbody.anime-list
|
||||
each item in animeList.Items
|
||||
tr.anime-list-item.mountable(title=item.Notes, data-api="/api/animelist/" + animeList.UserID + "/update/" + item.AnimeID)
|
||||
tr.anime-list-item(title=item.Notes, data-api="/api/animelist/" + animeList.UserID + "/update/" + item.AnimeID)
|
||||
td.anime-list-item-name
|
||||
a.ajax(href=item.Link(animeList.User().Nick))= item.Anime().Title.Canonical
|
||||
|
||||
if user != nil && item.Status == arn.AnimeListStatusWatching && item.Anime().EpisodeByNumber(item.Episodes + 1) != nil
|
||||
td.anime-list-item-actions
|
||||
for _, link := range item.Anime().EpisodeByNumber(item.Episodes + 1).Links
|
||||
a(href=link, title="Watch episode " + toString(item.Episodes + 1) + " on twist.moe", target="_blank", rel="noopener")
|
||||
RawIcon("eye")
|
||||
//- a(href=arn.Nyaa.GetLink(item.Anime()), title="Search on Nyaa", target="_blank", rel="noopener")
|
||||
//- RawIcon("download")
|
||||
|
||||
td.anime-list-item-airing-date
|
||||
if item.Anime().UpcomingEpisode() != nil
|
||||
if item.Status == arn.AnimeListStatusWatching && item.Anime().UpcomingEpisode() != nil
|
||||
span.utc-airing-date(data-start-date=item.Anime().UpcomingEpisode().Episode.AiringDate.Start, data-end-date=item.Anime().UpcomingEpisode().Episode.AiringDate.End, data-episode-number=item.Anime().UpcomingEpisode().Episode.Number)
|
||||
|
||||
td.anime-list-item-episodes
|
||||
.anime-list-item-episodes-watched
|
||||
.action(contenteditable=utils.SameUser(user, viewUser), data-field="Episodes", data-type="number", data-trigger="focusout", data-action="save")= item.Episodes
|
||||
@ -64,6 +63,7 @@ component AnimeList(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User
|
||||
//- .anime-list-item-episodes-edit
|
||||
//- a.ajax(href=, title="Edit anime")
|
||||
//- RawIcon("pencil")
|
||||
|
||||
td.anime-list-item-rating(title="Overall rating")
|
||||
.action(contenteditable=utils.SameUser(user, viewUser), data-field="Rating.Overall", data-type="number", data-trigger="focusout", data-action="save")= fmt.Sprintf("%.1f", item.Rating.Overall)
|
||||
//- td.anime-list-item-rating(title="Story rating")
|
||||
@ -72,8 +72,3 @@ component AnimeList(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User
|
||||
//- .action(contenteditable=utils.SameUser(user, viewUser), data-field="Rating.Visuals", data-type="number", data-trigger="focusout", data-action="save")= fmt.Sprintf("%.1f", item.Rating.Visuals)
|
||||
//- td.anime-list-item-rating(title="Soundtrack rating")
|
||||
//- .action(contenteditable=utils.SameUser(user, viewUser), data-field="Rating.Soundtrack", data-type="number", data-trigger="focusout", data-action="save")= fmt.Sprintf("%.1f", item.Rating.Soundtrack)
|
||||
|
||||
//- if user != nil
|
||||
//- td.anime-list-item-actions
|
||||
//- a(href=arn.Nyaa.GetLink(item.Anime()), title="Search on Nyaa", target="_blank", rel="noopener")
|
||||
//- RawIcon("download")
|
@ -8,11 +8,8 @@
|
||||
.anime-list
|
||||
vertical
|
||||
|
||||
tr
|
||||
horizontal
|
||||
|
||||
thead
|
||||
display none
|
||||
.anime-list-item
|
||||
horizontal
|
||||
|
||||
.anime-list-item-name
|
||||
flex 1
|
||||
@ -38,25 +35,16 @@
|
||||
flex 0.4
|
||||
opacity 0.5
|
||||
|
||||
// .anime-list-item-episodes-edit
|
||||
// flex 0.5
|
||||
.anime-list-item-rating
|
||||
text-align right
|
||||
|
||||
.anime-list-item-actions
|
||||
display none
|
||||
flex-basis 30px
|
||||
|
||||
// // Beautify icon alignment
|
||||
// .raw-icon
|
||||
// margin-bottom -2px
|
||||
|
||||
.anime-list-item-rating
|
||||
flex-basis 50px
|
||||
text-align center
|
||||
|
||||
.anime-list-item-actions
|
||||
flex-basis 40px
|
||||
text-align right
|
||||
display none
|
||||
|
||||
// Beautify icon alignment
|
||||
.raw-icon
|
||||
margin-bottom -4px
|
||||
// margin-bottom -4px
|
||||
|
||||
> 740px
|
||||
.anime-list-item-actions
|
||||
@ -68,6 +56,8 @@
|
||||
> 700px
|
||||
.anime-list-item-airing-date
|
||||
display block
|
||||
text-align right
|
||||
flex-basis 100px
|
||||
|
||||
< 1100px
|
||||
.anime-list-item-rating
|
||||
|
@ -102,7 +102,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
.profile-watching-list.mountable
|
||||
each item in animeList.Items
|
||||
a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
||||
img.anime-cover-image.profile-watching-list-item-image.lazy(data-src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical)
|
||||
img.profile-watching-list-item-image.lazy(data-src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical)
|
||||
|
||||
//- .profile-category.mountable
|
||||
//- h3
|
||||
|
@ -9,6 +9,11 @@
|
||||
width 55px !important
|
||||
height 78px !important
|
||||
border-radius 2px
|
||||
filter none
|
||||
transition filter transition-speed ease
|
||||
|
||||
:hover
|
||||
filter saturate(1.3)
|
||||
|
||||
// .status-tabs
|
||||
// position fixed
|
||||
|
17
patches/move-anime-episodes/move-anime-episodes.go
Normal file
17
patches/move-anime-episodes/move-anime-episodes.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
|
||||
func main() {
|
||||
for anime := range arn.MustStreamAnime() {
|
||||
arn.PanicOnError(arn.DB.Set("AnimeEpisodes", anime.ID, &arn.AnimeEpisodes{
|
||||
AnimeID: anime.ID,
|
||||
Items: anime.Episodes,
|
||||
}))
|
||||
|
||||
anime.Episodes = anime.Episodes[:0]
|
||||
anime.MustSave()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user