Replace --list-chapters and --list-formats with --info, include additional infos, update README, and some minor fixes and improvements
This commit is contained in:
parent
6bbc319d1b
commit
5d490de7f1
4 changed files with 114 additions and 106 deletions
|
@ -64,6 +64,8 @@ func (api *GtvApi) GetStreamEpisode(episode string) (StreamEpisode, error) {
|
|||
// Title
|
||||
json.Unmarshal(info_data, &ep)
|
||||
ep.Title = strings.ToValidUTF8(ep.Title, "")
|
||||
// Length
|
||||
ep.Length = ep.Length * time.Second
|
||||
// Sort Chapters, correct offset and set index
|
||||
sort.Slice(ep.Chapters, func(i int, j int) bool {
|
||||
return ep.Chapters[i].Offset < ep.Chapters[j].Offset
|
||||
|
@ -194,7 +196,7 @@ func (api *GtvApi) DownloadEpisode(
|
|||
// Handle Interrupts
|
||||
<-interruptChan
|
||||
keyboardInterrupt = true
|
||||
yield(DownloadProgress{Progress: progress, Rate: actualRate, Retries: 0, Title: ep.Title})
|
||||
yield(DownloadProgress{Aborted: true, Progress: progress, Rate: actualRate, Retries: 0, Title: ep.Title})
|
||||
}()
|
||||
for i, chunk := range chunklist.Chunks {
|
||||
if i < nextChunk {
|
||||
|
|
|
@ -13,8 +13,26 @@ var videoUrlRegex = regexp.MustCompile(`gronkh\.tv\/([a-z]+)\/([0-9]+)`)
|
|||
|
||||
//
|
||||
|
||||
type VideoFormat struct {
|
||||
Name string `json:"format"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type Chapter struct {
|
||||
Index int `json:"index"`
|
||||
Title string `json:"title"`
|
||||
Offset time.Duration `json:"offset"`
|
||||
}
|
||||
|
||||
type VideoTag struct {
|
||||
Id int `json:"id"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type GtvVideo struct {
|
||||
Class string `json:"class"`
|
||||
Category string `json:"category"`
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
|
@ -24,20 +42,13 @@ func ParseGtvVideoUrl(url string) (GtvVideo, error) {
|
|||
if len(match) < 2 {
|
||||
return video, errors.New("Could not parse URL " + url)
|
||||
}
|
||||
video.Class = match[1]
|
||||
video.Category = match[1]
|
||||
video.Id = match[2]
|
||||
return video, nil
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type VideoFormat struct {
|
||||
Name string `json:"format"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type ChunkList struct {
|
||||
BaseUrl string
|
||||
Chunks []string
|
||||
|
@ -65,21 +76,16 @@ func (cl *ChunkList) Cut(from time.Duration, to time.Duration) ChunkList {
|
|||
|
||||
//
|
||||
|
||||
type Chapter struct {
|
||||
Index int `json:"index"`
|
||||
Title string `json:"title"`
|
||||
Offset time.Duration `json:"offset"`
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type StreamEpisode struct {
|
||||
Episode string `json:"episode"`
|
||||
Formats []VideoFormat `json:"formats"`
|
||||
Title string `json:"title"`
|
||||
// ProposedFilename string `json:"proposed_filename"`
|
||||
PlaylistUrl string `json:"playlist_url"`
|
||||
Chapters []Chapter `json:"chapters"`
|
||||
Episode string `json:"episode"`
|
||||
Title string `json:"title"`
|
||||
Formats []VideoFormat `json:"formats"`
|
||||
Chapters []Chapter `json:"chapters"`
|
||||
PlaylistUrl string `json:"playlist_url"`
|
||||
Length time.Duration `json:"source_length"`
|
||||
Views int `json:"views"`
|
||||
Timestamp string `json:"created_at"`
|
||||
Tags []VideoTag `json:"tags"`
|
||||
}
|
||||
|
||||
func (ep *StreamEpisode) GetFormatByName(formatName string) (VideoFormat, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue