Temporary fix for Erai's inconsistent title uploading format
This commit is contained in:
parent
797bfde19d
commit
672826979c
120
cli.go
120
cli.go
@ -56,68 +56,78 @@ func (m *SubscriptionManager) Add() {
|
||||
fmt.Println()
|
||||
|
||||
// Get available subscriptions.
|
||||
fmt.Println("Available subscriptions:")
|
||||
titles, err := GetReleaseSchedule()
|
||||
if err != nil {
|
||||
fmt.Println("Unable to get release schedule.")
|
||||
return
|
||||
}
|
||||
// fmt.Println("Available subscriptions:")
|
||||
// titles, err := GetReleaseSchedule()
|
||||
// if err != nil {
|
||||
// fmt.Println("Unable to get release schedule.")
|
||||
// return
|
||||
// }
|
||||
|
||||
subMap := GetSubMap(&m.Subscriptions)
|
||||
// subMap := GetSubMap(&m.Subscriptions)
|
||||
|
||||
var available []string
|
||||
i := 0
|
||||
for _, title := range titles {
|
||||
title = strings.Split(title, " | ")[0]
|
||||
_, exists := subMap[title]
|
||||
if !exists {
|
||||
i++
|
||||
available = append(available, title)
|
||||
fmt.Println(fmt.Sprintf("\t[%02d] %v", i, title))
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
// var available []string
|
||||
// i := 0
|
||||
// for _, title := range titles {
|
||||
// title = strings.Split(title, " | ")[0]
|
||||
// _, exists := subMap[title]
|
||||
// if !exists {
|
||||
// i++
|
||||
// available = append(available, title)
|
||||
// fmt.Println(fmt.Sprintf("\t[%02d] %v", i, title))
|
||||
// }
|
||||
// }
|
||||
// fmt.Println()
|
||||
|
||||
// Get comma-separated list of additions.
|
||||
newSubs := []string{}
|
||||
var add string
|
||||
// var add string
|
||||
var name string
|
||||
for {
|
||||
fmt.Print("Add subscriptions. (M for manual): ")
|
||||
fmt.Scan(&add)
|
||||
add = strings.ToLower(add)
|
||||
if add == "m" {
|
||||
var err error
|
||||
fmt.Print("Name: ")
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
name, err = in.ReadString('\n')
|
||||
name = name[:len(name)-1]
|
||||
e.Panic(err)
|
||||
newSubs = append(newSubs, name)
|
||||
} else {
|
||||
addSplit := strings.Split(add, ",")
|
||||
retry := false
|
||||
for _, indexString := range addSplit {
|
||||
index, err := strconv.Atoi(indexString)
|
||||
if err != nil {
|
||||
fmt.Println("Error in indices. Try again.")
|
||||
retry = true
|
||||
break
|
||||
}
|
||||
if index <= 0 || index > len(available) {
|
||||
fmt.Fprintln(os.Stdout, "Error in indices. %v is invalid. Try again", index)
|
||||
retry = true
|
||||
break
|
||||
}
|
||||
|
||||
newSubs = append(newSubs, available[index-1])
|
||||
}
|
||||
if retry {
|
||||
continue
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
var err error
|
||||
fmt.Print("Name: ")
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
name, err = in.ReadString('\n')
|
||||
name = name[:len(name)-1]
|
||||
e.Panic(err)
|
||||
newSubs = append(newSubs, name)
|
||||
|
||||
|
||||
// for {
|
||||
// fmt.Print("Add subscriptions. (M for manual): ")
|
||||
// fmt.Scan(&add)
|
||||
// add = strings.ToLower(add)
|
||||
// if add == "m" {
|
||||
// var err error
|
||||
// fmt.Print("Name: ")
|
||||
// in := bufio.NewReader(os.Stdin)
|
||||
// name, err = in.ReadString('\n')
|
||||
// name = name[:len(name)-1]
|
||||
// e.Panic(err)
|
||||
// newSubs = append(newSubs, name)
|
||||
// } else {
|
||||
// addSplit := strings.Split(add, ",")
|
||||
// retry := false
|
||||
// for _, indexString := range addSplit {
|
||||
// index, err := strconv.Atoi(indexString)
|
||||
// if err != nil {
|
||||
// fmt.Println("Error in indices. Try again.")
|
||||
// retry = true
|
||||
// break
|
||||
// }
|
||||
// if index <= 0 || index > len(available) {
|
||||
// fmt.Fprintln(os.Stdout, "Error in indices. %v is invalid. Try again", index)
|
||||
// retry = true
|
||||
// break
|
||||
// }
|
||||
|
||||
// newSubs = append(newSubs, available[index-1])
|
||||
// }
|
||||
// if retry {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// break
|
||||
// }
|
||||
|
||||
var hevc string
|
||||
fmt.Print("Only HEVC? (Y/n): ")
|
||||
|
||||
14
main.go
14
main.go
@ -25,8 +25,7 @@ import (
|
||||
"github.com/mrobinsn/go-rtorrent/rtorrent"
|
||||
)
|
||||
|
||||
const ReleaseURL string = "https://www.erai-raws.info/release-schedule/"
|
||||
const RSSURL string = "https://www.erai-raws.info/feed/?res=1080p&type=magnet&subs%5B0%5D=us&v0=no&d157edc6b50f28b2776442c03d067d56"
|
||||
const ReleaseURL string = "https://www.erai-raws.info/release-schedule-v2/"
|
||||
const NyaaURL string = "https://nyaa.si/"
|
||||
|
||||
const SocketPath string = "/tmp/anitoru.sock"
|
||||
@ -141,11 +140,18 @@ func GetReleaseSchedule() ([]string, error) {
|
||||
res, err := http.Get(ReleaseURL)
|
||||
defer res.Body.Close()
|
||||
|
||||
e.Log("hello")
|
||||
|
||||
return titles, e.If(err).ThenIf(func() error { // The function will run first before return.
|
||||
doc, err = goquery.NewDocumentFromReader(res.Body)
|
||||
return err
|
||||
}).Then(func() {
|
||||
e.Log("here")
|
||||
doc.Find("html").Each(func(i int, s *goquery.Selection) {
|
||||
e.Log(s.Text())
|
||||
})
|
||||
doc.Find("table .aa_ss_ops_new").Each(func(i int, s *goquery.Selection) {
|
||||
e.Log(s.Text())
|
||||
titles = append(titles, strings.TrimSpace(s.Text()))
|
||||
})
|
||||
}).End()
|
||||
@ -219,9 +225,9 @@ func GetAllAvailable(name string, onlyHEVC bool) ([]Anime, error) {
|
||||
cols = cols.Next() // Filename
|
||||
title := cols.Text()
|
||||
|
||||
if !strings.Contains(title, "[ENG]") {
|
||||
/*if !strings.Contains(title, "[ENG]") {
|
||||
return
|
||||
}
|
||||
}*/
|
||||
|
||||
isHEVC := strings.Contains(title, "[HEVC]")
|
||||
if onlyHEVC && !isHEVC {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user