mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Fix 1080p, 720p, ... not working
This commit is contained in:
parent
afa975c459
commit
0fa829828f
2 changed files with 13 additions and 5 deletions
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/grafov/m3u8"
|
"github.com/grafov/m3u8"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
@ -98,9 +99,12 @@ var archiveCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
switch archiveResolutionFlag {
|
switch archiveResolutionFlag {
|
||||||
case "1080p", "720p", "480p", "360p", "240p":
|
case "1080p", "720p", "480p", "360p":
|
||||||
intRes, _ := strconv.ParseFloat(strings.TrimSuffix(archiveResolutionFlag, "p"), 84)
|
intRes, _ := strconv.ParseFloat(strings.TrimSuffix(downloadResolutionFlag, "p"), 84)
|
||||||
archiveResolutionFlag = fmt.Sprintf("%dx%s", int(intRes*(16/9)), strings.TrimSuffix(archiveResolutionFlag, "p"))
|
archiveResolutionFlag = fmt.Sprintf("%.0fx%s", math.Ceil(intRes*(float64(16)/float64(9))), strings.TrimSuffix(downloadResolutionFlag, "p"))
|
||||||
|
case "240p":
|
||||||
|
// 240p would round up to 427x240 if used in the case statement above, so it has to be handled separately
|
||||||
|
archiveResolutionFlag = "428x240"
|
||||||
case "1920x1080", "1280x720", "640x480", "480x360", "428x240", "best", "worst":
|
case "1920x1080", "1280x720", "640x480", "480x360", "428x240", "best", "worst":
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("'%s' is not a valid resolution", archiveResolutionFlag)
|
return fmt.Errorf("'%s' is not a valid resolution", archiveResolutionFlag)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/ByteDream/crunchyroll-go/v2/utils"
|
"github.com/ByteDream/crunchyroll-go/v2/utils"
|
||||||
"github.com/grafov/m3u8"
|
"github.com/grafov/m3u8"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -53,9 +54,12 @@ var downloadCmd = &cobra.Command{
|
||||||
out.Debug("Locales: audio: %s / subtitle: %s", downloadAudioFlag, downloadSubtitleFlag)
|
out.Debug("Locales: audio: %s / subtitle: %s", downloadAudioFlag, downloadSubtitleFlag)
|
||||||
|
|
||||||
switch downloadResolutionFlag {
|
switch downloadResolutionFlag {
|
||||||
case "1080p", "720p", "480p", "360p", "240p":
|
case "1080p", "720p", "480p", "360p":
|
||||||
intRes, _ := strconv.ParseFloat(strings.TrimSuffix(downloadResolutionFlag, "p"), 84)
|
intRes, _ := strconv.ParseFloat(strings.TrimSuffix(downloadResolutionFlag, "p"), 84)
|
||||||
downloadResolutionFlag = fmt.Sprintf("%dx%s", int(intRes*(16/9)), strings.TrimSuffix(downloadResolutionFlag, "p"))
|
downloadResolutionFlag = fmt.Sprintf("%.0fx%s", math.Ceil(intRes*(float64(16)/float64(9))), strings.TrimSuffix(downloadResolutionFlag, "p"))
|
||||||
|
case "240p":
|
||||||
|
// 240p would round up to 427x240 if used in the case statement above, so it has to be handled separately
|
||||||
|
downloadResolutionFlag = "428x240"
|
||||||
case "1920x1080", "1280x720", "640x480", "480x360", "428x240", "best", "worst":
|
case "1920x1080", "1280x720", "640x480", "480x360", "428x240", "best", "worst":
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("'%s' is not a valid resolution", downloadResolutionFlag)
|
return fmt.Errorf("'%s' is not a valid resolution", downloadResolutionFlag)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue