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

Missing value for BANDWIDTH #64

Closed
kmod-midori opened this issue Mar 1, 2021 · 3 comments · Fixed by #69
Closed

Missing value for BANDWIDTH #64

kmod-midori opened this issue Mar 1, 2021 · 3 comments · Fixed by #69
Labels
A-parser Area: parser E-easy Effort: easy. A task that would be a great starting point for a new contributor. good first issue Good for newcomers T-bug Type: bug. Something isn't working. T-config Should be configurable in the future

Comments

@kmod-midori
Copy link

I got the following m3u8 from a CDN server:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=10000000
https://995107575.cloudvdn.com/a.m3u8?cdn=cn-gotcha03&domain=d1--cn-gotcha103.bilivideo.com&expires=1614619920&len=0&oi=1891753406&order=1&player=70YAALwcl0b9RGgW&pt=h5&ptype=0&qn=10000&secondToken=secondToken%3ACZ4ggpPHomuwcnT8XWDjJUp9eh8&sign=325afc8bc3b01ccbadeac084004ece64&sigparams=cdn%2Cexpires%2Clen%2Coi%2Cpt%2Cqn%2Ctrid&sl=1&src=4&streamid=live-qn%3Alive-qn%2Flive_402401719_42665292&trid=20d9f245179b4ef3a7e3635afaaa87ea&v3=1

Parsing this gives me a

 [src\main.rs:14] MasterPlaylist::try_from(s) = Err(
    Error {
        inner: MissingValue {
            value: "BANDWIDTH",
        },
    },
)

with the following code

let s = "#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=10000000
https://995107575.cloudvdn.com/a.m3u8?cdn=cn-gotcha03&domain=d1--cn-gotcha103.bilivideo.com&expires=1614619920&len=0&oi=1891753406&order=1&player=70YAALwcl0b9RGgW&pt=h5&ptype=0&qn=10000&secondToken=secondToken%3ACZ4ggpPHomuwcnT8XWDjJUp9eh8&sign=325afc8bc3b01ccbadeac084004ece64&sigparams=cdn%2Cexpires%2Clen%2Coi%2Cpt%2Cqn%2Ctrid&sl=1&src=4&streamid=live-qn%3Alive-qn%2Flive_402401719_42665292&trid=20d9f245179b4ef3a7e3635afaaa87ea&v3=1";
dbg!(MasterPlaylist::try_from(s));

This can not be a formatting issue as feeding the parser with the exact response string yields the same result. Am I doing something wrong?

@Luro02
Copy link
Collaborator

Luro02 commented Mar 5, 2021

Hey, I am currently quite busy with university exams, so it might take a while until I fix this issue (eta. would be end of march).

You know that there is a space between the PROGRAM-ID=1, BANDWIDTH=10000000. From where did you obtain this m3u8 file? Did you create it yourself or was it made by someone else?

Either way to fix this, you have to make the following changes:

            self.index = end + 1;

-            &self.string[start..end]
+            // remove trailing and leading whitespace from the key
+            (&self.string[start..end]).trim()

(src/attribute.rs#L33)
and

            };

            self.index += end;
            self.index -= start;

-            &self.string[start..end]
+            // remove trailing and leading whitespace from the value
+            (&self.string[start..end]).trim()
        };

(src/attribute.rs#L69)

Feel free to create a PR for this issue, if you do not want to wait for me to fix it. It would also be nice to have tests in the attribute.rs file for both changes (so this issue does not happen again).

I hope you have a nice day :)

@Luro02 Luro02 added A-parser Area: parser E-easy Effort: easy. A task that would be a great starting point for a new contributor. good first issue Good for newcomers T-bug Type: bug. Something isn't working. labels Mar 5, 2021
@Luro02
Copy link
Collaborator

Luro02 commented Mar 5, 2021

To quote the RFC:

Certain tags have values that are attribute-lists. An attribute-list
is a comma-separated list of attribute/value pairs with no
whitespace.

https://tools.ietf.org/html/rfc8216#section-4.2

#27

@Luro02 Luro02 added the T-config Should be configurable in the future label Mar 5, 2021
@kmod-midori
Copy link
Author

Oh... didn't know that that file is malformed, as I got it from a CDN of a video distribution service. Both hls.js and the Node.js library I'm using in other projects seem to handle this fine.

Will look into PR this when I have time.

Luro02 added a commit to Luro02/hls_m3u8 that referenced this issue Oct 1, 2021
@Luro02 Luro02 mentioned this issue Oct 1, 2021
@Luro02 Luro02 closed this as completed in #69 Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: parser E-easy Effort: easy. A task that would be a great starting point for a new contributor. good first issue Good for newcomers T-bug Type: bug. Something isn't working. T-config Should be configurable in the future
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants