refactor: simplify playlist name extraction using strings.CutPrefix
This commit is contained in:
@@ -31,8 +31,8 @@ func (s *playlists) parseM3U(ctx context.Context, pls *model.Playlist, folder *m
|
|||||||
filteredLines := make([]string, 0, len(lines))
|
filteredLines := make([]string, 0, len(lines))
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
line := strings.TrimSpace(line)
|
line := strings.TrimSpace(line)
|
||||||
if strings.HasPrefix(line, "#PLAYLIST:") {
|
if after, ok := strings.CutPrefix(line, "#PLAYLIST:"); ok {
|
||||||
pls.Name = line[len("#PLAYLIST:"):]
|
pls.Name = after
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if after, ok := strings.CutPrefix(line, "#EXTALBUMARTURL:"); ok {
|
if after, ok := strings.CutPrefix(line, "#EXTALBUMARTURL:"); ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user