Skip to content

Commit

Permalink
add select Sampling rate
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed May 30, 2024
1 parent 2a4e557 commit 019689b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ atmos-save-folder: AM-DL-Atmos downloads
check: ""
force-api: false
get-m3u8-from-device: false
alac-max: 192000 #192000 96000 48000 44100
atmos-max: 2768 #2768 2448
17 changes: 12 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Config struct {
ForceApi bool `yaml:"force-api"`
Check string `yaml:"check"`
GetM3u8FromDevice bool `yaml:"get-m3u8-from-device"`
AlacMax int `yaml:"alac-max"`
}

var config Config
Expand Down Expand Up @@ -1495,13 +1496,19 @@ func extractMedia(b string) (string, []string, error) {
if variant.Codecs == "alac" {
split := strings.Split(variant.Audio, "-")
length := len(split)
fmt.Printf("%s-bit / %s Hz\n", split[length-1], split[length-2])
streamUrlTemp, err := masterUrl.Parse(variant.URI)
length_int,err := strconv.Atoi(split[length-2])
if err != nil {
panic(err)
return "", nil, err
}
if length_int <= config.AlacMax{
fmt.Printf("%s-bit / %s Hz\n", split[length-1], split[length-2])
streamUrlTemp, err := masterUrl.Parse(variant.URI)
if err != nil {
panic(err)
}
streamUrl = streamUrlTemp
break
}
streamUrl = streamUrlTemp
break
}
}
if streamUrl == nil {
Expand Down
19 changes: 14 additions & 5 deletions main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Config struct {
CoverFormat string `yaml:"cover-format"`
AlacSaveFolder string `yaml:"alac-save-folder"`
AtmosSaveFolder string `yaml:"atmos-save-folder"`
AtmosMax int `yaml:"atmos-max"`
}

var config Config
Expand Down Expand Up @@ -1363,13 +1364,21 @@ func extractMedia(b string) (string, []string, error) {
})
for _, variant := range master.Variants {
if variant.Codecs == "ec-3" {
fmt.Printf("%s\n", variant.Audio)
streamUrlTemp, err := masterUrl.Parse(variant.URI)
split := strings.Split(variant.Audio, "-")
length := len(split)
length_int,err := strconv.Atoi(split[length-1])
if err != nil {
panic(err)
return "", nil, err
}
if length_int <= config.AtmosMax{
fmt.Printf("%s\n", variant.Audio)
streamUrlTemp, err := masterUrl.Parse(variant.URI)
if err != nil {
panic(err)
}
streamUrl = streamUrlTemp
break
}
streamUrl = streamUrlTemp
break
}
}
if streamUrl == nil {
Expand Down
17 changes: 12 additions & 5 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Config struct {
CoverFormat string `yaml:"cover-format"`
AlacSaveFolder string `yaml:"alac-save-folder"`
AtmosSaveFolder string `yaml:"atmos-save-folder"`
AlacMax int `yaml:"alac-max"`
}

var config Config
Expand Down Expand Up @@ -1415,13 +1416,19 @@ func extractMedia(b string) (string, []string, error) {
if variant.Codecs == "alac" {
split := strings.Split(variant.Audio, "-")
length := len(split)
fmt.Printf("%s-bit / %s Hz\n", split[length-1], split[length-2])
streamUrlTemp, err := masterUrl.Parse(variant.URI)
length_int,err := strconv.Atoi(split[length-2])
if err != nil {
panic(err)
return "", nil, err
}
if length_int <= config.AlacMax{
fmt.Printf("%s-bit / %s Hz\n", split[length-1], split[length-2])
streamUrlTemp, err := masterUrl.Parse(variant.URI)
if err != nil {
panic(err)
}
streamUrl = streamUrlTemp
break
}
streamUrl = streamUrlTemp
break
}
}
if streamUrl == nil {
Expand Down

0 comments on commit 019689b

Please sign in to comment.