Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Некорректный парсинг #EXT-X-DISCONTINUITY #7

Closed
THE108 opened this issue Oct 16, 2014 · 1 comment
Closed

Некорректный парсинг #EXT-X-DISCONTINUITY #7

THE108 opened this issue Oct 16, 2014 · 1 comment
Assignees
Labels

Comments

@THE108
Copy link

THE108 commented Oct 16, 2014

Привет!!

По-моему у тебя некорректно парсится #EXT-X-DISCONTINUITY: в reader.go

    case !state.tagInf && strings.HasPrefix(line, "#EXTINF:"):
        state.tagInf = true
        state.listType = MEDIA
        params := strings.SplitN(line[8:], ",", 2)
        if state.duration, err = strconv.ParseFloat(params[0], 64); strict && err != nil {
            return errors.New(fmt.Sprintf("Duration parsing error: %s", err))
        }
        title = params[1]
    case !state.tagDiscontinuity && strings.HasPrefix(line, "#EXT-X-DISCONTINUITY"):
        state.tagDiscontinuity = true
        state.listType = MEDIA
    case !strings.HasPrefix(line, "#"):
        if state.tagInf {
            p.Append(line, state.duration, title)
            state.tagInf = false
        } else if state.tagRange {
            if err = p.SetRange(state.limit, state.offset); strict && err != nil {
                return err
            }
            state.tagRange = false
        } else if state.tagDiscontinuity {
            state.tagDiscontinuity = false
            if err = p.SetDiscontinuity(); strict && err != nil {
                return err
            }
        } else if state.tagProgramDateTime {
            state.tagProgramDateTime = false
            if err = p.SetProgramDateTime(state.programDateTime); strict && err != nil {
                return err
            }
        }

В блоке case !strings.HasPrefix(line, "#"), если до этого выставлено в true два флага - tagInf и tagDiscontinuity, Discontinuity не выставится, т.к. ты используешь if else вместо if.

Я это обошел, проставив перевод строки после чанка с Discontinuity, чтобы зайти в вышеназванную секцию два раза!

Может это по стандарту надо ставить перевод строки?

@grafov grafov self-assigned this Nov 9, 2014
@grafov
Copy link
Owner

grafov commented Feb 1, 2015

Таки это баг, забыл пофиксить.

@grafov grafov added the bug label Feb 1, 2015
@grafov grafov closed this as completed in 6732a16 Feb 1, 2015
grafov added a commit that referenced this issue Nov 22, 2016
It also apply to EXT-X-PROGRAM-DATE-TIME parsing.
Unit tests updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants