mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-11 15:56:37 +08:00
Fix media scraping rename and compose pulls
This commit is contained in:
@@ -69,7 +69,7 @@ type nfoDocument struct {
|
||||
OriginalTitle string `xml:"originaltitle"`
|
||||
SortTitle string `xml:"sorttitle"`
|
||||
Num string `xml:"num"`
|
||||
Year int `xml:"year"`
|
||||
Year nfoInt `xml:"year"`
|
||||
Premiered string `xml:"premiered"`
|
||||
ReleaseDate string `xml:"releasedate"`
|
||||
Release string `xml:"release"`
|
||||
@@ -77,15 +77,15 @@ type nfoDocument struct {
|
||||
Plot string `xml:"plot"`
|
||||
Outline string `xml:"outline"`
|
||||
OriginalPlot string `xml:"originalplot"`
|
||||
Rating float32 `xml:"rating"`
|
||||
Rating nfoFloat `xml:"rating"`
|
||||
Poster string `xml:"poster"`
|
||||
Thumbs []nfoThumb `xml:"thumb"`
|
||||
Fanart nfoFanart `xml:"fanart"`
|
||||
Art nfoArt `xml:"art"`
|
||||
TMDbID int `xml:"tmdbid"`
|
||||
TMDbID nfoInt `xml:"tmdbid"`
|
||||
UniqueIDs []nfoUniqueID `xml:"uniqueid"`
|
||||
Season int `xml:"season"`
|
||||
Episode int `xml:"episode"`
|
||||
Season nfoInt `xml:"season"`
|
||||
Episode nfoInt `xml:"episode"`
|
||||
Genres []string `xml:"genre"`
|
||||
Tags []string `xml:"tag"`
|
||||
Countries []string `xml:"country"`
|
||||
@@ -98,6 +98,46 @@ type nfoDocument struct {
|
||||
Actors []nfoActor `xml:"actor"`
|
||||
}
|
||||
|
||||
type nfoInt int
|
||||
|
||||
func (n *nfoInt) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||
var raw string
|
||||
if err := d.DecodeElement(&raw, &start); err != nil {
|
||||
return err
|
||||
}
|
||||
raw = cleanXMLText(raw)
|
||||
if raw == "" || strings.EqualFold(raw, "none") || strings.EqualFold(raw, "null") || strings.EqualFold(raw, "nan") {
|
||||
*n = 0
|
||||
return nil
|
||||
}
|
||||
if v, err := strconv.Atoi(raw); err == nil {
|
||||
*n = nfoInt(v)
|
||||
return nil
|
||||
}
|
||||
if f, err := strconv.ParseFloat(raw, 64); err == nil {
|
||||
*n = nfoInt(int(f))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type nfoFloat float32
|
||||
|
||||
func (n *nfoFloat) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||
var raw string
|
||||
if err := d.DecodeElement(&raw, &start); err != nil {
|
||||
return err
|
||||
}
|
||||
raw = cleanXMLText(raw)
|
||||
if raw == "" || strings.EqualFold(raw, "none") || strings.EqualFold(raw, "null") || strings.EqualFold(raw, "nan") {
|
||||
*n = 0
|
||||
return nil
|
||||
}
|
||||
if v, err := strconv.ParseFloat(raw, 32); err == nil {
|
||||
*n = nfoFloat(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type nfoActor struct {
|
||||
Name string `xml:"name"`
|
||||
Role string `xml:"role"`
|
||||
@@ -253,16 +293,16 @@ func metadataFromDoc(doc *nfoDocument, baseDir string, seriesLike bool) *LocalMe
|
||||
Title: cleanXMLText(doc.Title),
|
||||
OriginalName: cleanXMLText(doc.OriginalTitle),
|
||||
AdultCode: normalizeAdultCode(doc.Num),
|
||||
Year: doc.Year,
|
||||
Year: int(doc.Year),
|
||||
Overview: firstText(doc.Plot, doc.Outline, doc.OriginalPlot),
|
||||
Rating: doc.Rating,
|
||||
Rating: float32(doc.Rating),
|
||||
PosterURL: firstRemoteURL(baseDir, nfoPosterValues(doc)...),
|
||||
BackdropURL: firstRemoteURL(baseDir, nfoBackdropValues(doc)...),
|
||||
TMDbID: doc.TMDbID,
|
||||
TMDbID: int(doc.TMDbID),
|
||||
DoubanID: externalIDFromUniqueIDs(doc.UniqueIDs, "douban"),
|
||||
TheTVDBID: externalIDFromUniqueIDs(doc.UniqueIDs, "thetvdb", "tvdb"),
|
||||
SeasonNum: doc.Season,
|
||||
EpisodeNum: doc.Episode,
|
||||
SeasonNum: int(doc.Season),
|
||||
EpisodeNum: int(doc.Episode),
|
||||
Genres: joinNFOValues(adultAwareGenres(doc)),
|
||||
Countries: joinNFOValues(doc.Countries),
|
||||
Languages: joinNFOValues(doc.Languages),
|
||||
|
||||
Reference in New Issue
Block a user