Skip to content

Commit

Permalink
add find m3u8 from txt
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed Apr 30, 2024
1 parent c25feac commit 35e5657
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
3. 运行结束后显示总体完成情况
4. 自动内嵌封面和LRC歌词(需要media-user-token,获取方式看最后的说明)
5. 自动构建 可以到 [Actions](https://github.com/zhaarey/apple-music-alac-atmos-downloader/actions) 页面下载最新自动构建版本 可以直接`main.exe url`
6. main_select 支持手动填写m3u8,输入#号
6. main_select 支持手动填写m3u8,输入#号,比如#1 #2,支持txt读取m3u8,输入txt文件名



Expand Down
32 changes: 32 additions & 0 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,18 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println(err)
}
manually := false
manually_txt := false
m3u8_txt := ""
if strings.Contains(input, "txt") {
m3u8_txt= strings.TrimSpace(input)
fmt.Print(m3u8_txt)
strArr := make([]string, len(arr))
for i, num := range arr {
strArr[i] = strconv.Itoa(num)
}
input = strings.Join(strArr, " ")
manually_txt = true
}
if strings.Contains(input, "#") {
input = strings.ReplaceAll(input, "#", "")
manually = true
Expand Down Expand Up @@ -1216,6 +1228,26 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println("Track already exists locally.")
continue
}
if manually_txt {
file, err := os.Open(m3u8_txt)
if err != nil {
fmt.Println("cant open txt:", err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, track.ID) {
parts := strings.SplitN(line, ",", 2)
if len(parts) == 2 {
manifest.Attributes.ExtendedAssetUrls.EnhancedHls=parts[1]
}
}
}
if err := scanner.Err(); err != nil {
fmt.Println(err)
}
}
if manually {
fmt.Print("m3u8: ")
reader := bufio.NewReader(os.Stdin)
Expand Down

0 comments on commit 35e5657

Please # to comment.