Skip to content

Commit

Permalink
fix: remove options (broken?) and improve the url extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloo27 committed May 14, 2024
1 parent 2e46a06 commit 4e2548d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions player/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,15 @@ func extractVideoURL(result *search.SearchResult) (string, error) {
if err != nil {
return "", nil
}
return defaultClient.GetStreamURL(vid, &vid.Formats.Itag(140)[0])

formats := vid.Formats.Itag(251)

if len(formats) > 0 {
format := formats[0]
return defaultClient.GetStreamURL(vid, &format)
}

return defaultClient.GetStreamURL(vid, &vid.Formats[0])
}

func PlaySearchResult(result *search.SearchResult, playlist *storage.Playlist) error {
Expand Down Expand Up @@ -262,21 +270,13 @@ func escapeTitle(title string) string {
}

func LoadFile(filePath, title string) error {
var options string
if title != "" {
options = fmt.Sprintf("force-media-title=%s", escapeTitle(title))
}
err := MpvInstance.Command([]string{"loadfile", filePath, "replace", options})
err := MpvInstance.Command([]string{"loadfile", filePath, "replace"})
callHooks(HookFileLoadStarted, err, filePath)
return err
}

func AppendFile(filePath, title string) error {
var options string
if title != "" {
options = fmt.Sprintf("force-media-title=%s", escapeTitle(title))
}
err := MpvInstance.Command([]string{"loadfile", filePath, "append", options})
err := MpvInstance.Command([]string{"loadfile", filePath, "append"})
callHooks(HookFileLoadStarted, err, filePath)
return err
}
Expand Down

0 comments on commit 4e2548d

Please sign in to comment.