Skip to content

Commit

Permalink
Merge pull request #3 from aerovulpe/2-support-entry-elements-with-em…
Browse files Browse the repository at this point in the history
…pty-strings

Support playlist entry elements with empty strings
  • Loading branch information
kirill-gr authored Jun 9, 2019
2 parents 9c18cde + 69910c0 commit 3c649d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/antlr/M3uLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FILE_START: '#EXTM3U';
CHANNEL_START: EXTINF;
NUMBER: '-'? DIGIT+;
SAFE_STRING: SAFE_CHAR+;
QUOTED_STRING: QUOTE (SAFE_CHAR | NUMBER | COLON | EQUALS | SPACES | COMMA)+ QUOTE;
QUOTED_STRING: QUOTE (SAFE_CHAR | NUMBER | COLON | EQUALS | SPACES | COMMA)* QUOTE;
COMMA: ',' -> pushMode(CHANNEL_DESC);
COLON: ':';
EQUALS: '=';
Expand Down
10 changes: 10 additions & 0 deletions src/test/kotlin/ru/grushetsky/m3uparser/M3uParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,14 @@ class M3uParserTest {

assertThat(fileParser.entries().entry_info().size).isEqualTo(2)
}

@Test
fun `entry elements with empty string detected correctly`() {
val entryParser = getParser(getResourceAsString("/entry_with_empty_string.txt")).entry_info()

assertThat(entryParser.enrty_basic_info().entry_name().text).isEqualTo("Channel 1")
assertThat(entryParser.enrty_basic_info().entry_uri().text).isEqualTo("http://1.2.3.4:1234/udp/4.3.2.1:5678")
assertThat(entryParser.parameters().parameter().size).isEqualTo(4)
assertThat(entryParser.length().text).isEqualTo("-1")
}
}
3 changes: 3 additions & 0 deletions src/test/resources/entry_with_empty_string.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#EXTINF:-1 tvg-name="Channel_1" tvg-logo=""
tvg-shift=a0 aspect-ratio=16:9,Channel 1
http://1.2.3.4:1234/udp/4.3.2.1:5678

0 comments on commit 3c649d3

Please sign in to comment.