mirror of
https://github.com/rutgersc/m3u8-rs.git
synced 2024-11-15 21:21:08 +00:00
Fix consume_line
not returning line when line doesn't end with a newline
This commit is contained in:
parent
cd9402051e
commit
087c47bddd
3 changed files with 34 additions and 7 deletions
23
sample-playlists/master-not-ending-in-newline-1.m3u8
Normal file
23
sample-playlists/master-not-ending-in-newline-1.m3u8
Normal file
|
@ -0,0 +1,23 @@
|
|||
#EXTM3U
|
||||
#EXT-X-TWITCH-INFO:NODE="video-edge-346990.cph01",MANIFEST-NODE-TYPE="weaver_cluster",MANIFEST-NODE="video-weaver.cph01",SUPPRESS="false",SERVER-TIME="1603666310.03",TRANSCODESTACK="2017TranscodeX264_V2",USER-IP="81.228.244.140",SERVING-ID="2e8913ca31ab4d54988d8dd87a66d3eb",CLUSTER="cph01",ABS="false",VIDEO-SESSION-ID="709300939666498958",BROADCAST-ID="40219312190",STREAM-TIME="10225.032456",B="false",USER-COUNTRY="SE",MANIFEST-CLUSTER="cph01",ORIGIN="sjc02",C="aHR0cHM6Ly92aWRlby1lZGdlLTNlN2UyOC5wZHgwMS5hYnMuaGxzLnR0dm53Lm5ldC92MS9zZWdtZW50L0NtSVk5WlFDUWp1eTFjMmo0WFB0LUM0eDhSWWZpdlRnRjl6dDJQT083WlRPdzYybC14bkpnYnJxanlBTl82eExfWlcxeS1PS1NyUFBQZnpaSUI0VGxYS3k4YmFvMEpUVjQ0X1Q2X215b1dKZ3NDaVBWaU5CMjIyTlljd2VpQVpaTUxHUElER1ExY1dla1hvejc3LTRPU1BqRVhpUmNDVnM5ZmFnMkVLblk5UTZjaldDaTZwSldVTjl2N01femVRZ1VsSU5YNDNIdFh4RU1ORU5sT2hZX1RXRjExRmJqRVdjMW9OYkRva191c3g0WHdwb29ETVFFZ2Z1NlJFV0pRRERFdGhTTVJDN3J3SFVFb3c4aG9PN0VLQmFOVG1zTGpIUjZ6S3R3RS1nblptRk1HSWFSQ2V6NWtzTlVOREhidW45RXlOOFdIeWJaVG1rZlpfQm9MRjZScXBpbnNUYkJGT0I1VWJUYnFjbU50RnBFcGs5ejFBU29zZHNvM0ZJNGplWWZUU3lIYTFSQU11a0YwQXBJZjNmNHZDaVpNdFN3amh6aFl1Z2dsNnM0a0ZZSWdKUVBPMUhGWktlMjFtak1BOHBycFJoV2NqazN1Z2VvUnI2VGt0S3dzSmdBVjVrWmlRUm9TZ1V5ZE5UUmZJa1hIay1nM1JBaW1FcGpiWnVUYnd0UVRFSjhpNUhBdGtTd25ZUm01WUhrTlpVVnU0TlJyZDdiaElDTEZVWW1xSlRLR3hSU0NXXzRteXlmc0JYeXZFQWFhVFNTLTBtb0dSTmpGZEl5TlotOVN2U3pKZ0UxRkJiSk9pdTVGS1phTDlzNGl3NHYySXJITUF3dDkwbkxWN1QzNTVQQTVIN0pRTlk3MXZMTUNtZGNMMkY4RG1BTE1JNl9lbEZEeml5dThhRFlieXZjbi1LXzJWZmk2azBONjNGSnBKU0F3bDZyaG01Um80bVJ2NFc0TDl3V3JacTNhblNxR2wxWlZJejBUNnZlcFRYU3l5UVl6dzRPYmZ1S0l6OVNGdFNnb0JvSmFiLnRz",D="false"
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="chunked",NAME="1080p60 (source)",AUTOSELECT=YES,DEFAULT=YES
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=9061127,RESOLUTION=1920x1080,CODECS="avc1.64002A,mp4a.40.2",VIDEO="chunked"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/Cu0DdhlwnpcIE03_B0CE88V9Oqeqod_rQRgGhkHtC_a8kMVJczhYuLCbGc04CMESYcRvucOJJccCANfsfli1hJPoqruJD7u9ETSxMIcNUfT54D52gA55ePJXxM5IUddHwZ5lw1vPC4IFC0IPVeUvRFw5g8HbCgRAJD-YV2W90VVcbXoCnNoLtvk_IJYwVk59XGECSzWh9lRRXTuqHgOWaehnTOvBcNLGl_BovpgqnLcMjeJTLhIO9Sna8JqM3ppnl19M8AE9RqrI6P4qsQRPcOmwa19Xx8n7yhBcrkMHVJhatHhUIVnOJ99fmgTul9NPBtRhcn59AVSCcNHrjrMwK0LTWmkD-8rmZaG2ezrLVbC6TzR9LfPsYVPokmAKDyUdOdai0gEMoWI8MvD17gl5bgoWrUHNk458cbtN8PaNrrbRbTC5fweA3Qo4mo4QNv1qOwi2inwKV3Jq81y6A0WG9gq-xQlQQaTk9r_XPnkqmuAFW_SlXHC7fdT8ZQHr3LxvzsQgjBrTo935EK269CMU3uuzOiQIphR0N-NJormgedjw5sZ6WT1N-1UWSliEqJ2CP1F89fPGDfB0Zxi8RUWNY7FJDJBWaofXumtBkObhmUqaPQtm5yq2rto89e0mOFx8pOzFCH556zu0vuHZ4ua4OxIQ3gR52zVBOaNMWs8PGJ7UARoMYEeMrBQEwEssMiG4.m3u8
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="720p60",NAME="720p60",AUTOSELECT=YES,DEFAULT=YES
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=3430252,RESOLUTION=1280x720,CODECS="avc1.4D401F,mp4a.40.2",VIDEO="720p60"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/CusDfH81q-R4CeLFl4jpTunvTt4JycqLEY4s_ysCUBub4j9pBZ-_6XcUIrWcfAgyaxFDNk7U6OkUYiD2jLTsvR4fzLGLzjnCyi604bDe_hek8719_WGgzVYEH6NuqauU_5C0DN6_h79PjTHkdu2Ty3WVlO4wg1nONk1m79n5DyEuxZOWuSQVZ5EIXxRWTMWbJxRNnW-jONMCAogfwrhIckgLOJIHjALdyBKEj7RFLGTsInfK59l7q81FsWFZztgrpIRjOteUdwJpWgnMpSK17rA-Rpy_KaU0oZKVslYMA7ZN2SLh808PKg28A6pqECZYu99Mpi6u_vo9WLU77igUi-P1UWEtuWEBXSPLQ1e5CSlBl7N_O13davOU7VndT8DZXgRwSlv_l3PmUQHG93BNdjxUpxzuc1lUKyde-M0xjhIBqQaYiwZ8UJeEWhuGbG1lsrCEzrsWMwo-FgBIakfVCMVCyQJk2w7E5bscPSQBuXLt4wlYUJZE5oSCGIj58xYZGmXd9ziUho5hH2KX5QA53nwcj4pbwfc-a4kE3ei12XuzCdsnjOgN1MxfCH2lfqHzGk9qxkPAF78e3nXU3U-wud8ZqMpYMXuGtf3ieA8bcXbrT_TftnA2KF1OaZ_Cn0Sv2qp6LHWkcAPPBe1KxkUSELv_6WHWmQDFpHKMYFMXTqgaDMDj0TLeNq1d00BBTw.m3u8
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="720p30",NAME="720p",AUTOSELECT=YES,DEFAULT=YES
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=2380252,RESOLUTION=1280x720,CODECS="avc1.4D401F,mp4a.40.2",VIDEO="720p30"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/CusDrxckkPKJOGpcsyTyuBoy-pTZVCqHuHQzm7N0fmyFc165xORl03bTfVbTY694T2U5WFAir8n62naHRMRgqJGJbvWyPx3lSetz6nKH-mY3TeDv-irBc6AEWfUbMmd5Nfh22CFBg__4iQxgvhru8TDlSDI2jR2pGkWCkN72bGN7iT6AXVcXTg_LVl1Tv1L7Sk8DFXm4jNHUPZo6utaYQ1jzlkEESTUE9PnXqrRRhIsm1HsCLsiUWZuBXyqgSbvJRl9LA1lFSoWEl-oGksc9BtFC5J25589KAc2vbvJpRvkiROlJaSwhD0m2LeOM9MiYU4HsFx94g8EC6WZrIQjWAVn7bcGAey0nsMZbWwBh38nCfRuk4Zh5AR2OvAmYMgFhT8s2kLxUhcrcMzJJpKVF15gRx1xwB4caFMVjtRNulVutR7acOJTVpftf-b2A8nWUiB_EdKTFjhOagYDbMFKUEEhWh159xir1YaVG4bu8qqsxroiToAqiB2MdbpxZnAWE8-ByJ_TgYBTFF7mu2WxTxT58cslGVR1B5EXlg-9RuzJFnE8uxgcwzWyN_lQK6DbIEV9Ge1rQp8HczxZ6Ly1W7OOZ1t8TNaljH0Aq_ZAvuZY-9L5N_pnfzLyk4rhLOsw-W3dk8y2R4jKAMch8QS4SEPqbvo6S7IXCMcEvS2qlWXYaDMVPpybtHPQRXtOUGw.m3u8
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="480p30",NAME="480p",AUTOSELECT=YES,DEFAULT=YES
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=1435252,RESOLUTION=852x480,CODECS="avc1.4D401F,mp4a.40.2",VIDEO="480p30"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/CusDzVCKhT87Cu678cooYX0w6oTbF6DmpnQ2XeBqjM2ru-PpHq7qOeI-ETldFN3cOQBpLWXv_s0wwNIqXei9MeK-teHn4NBK-U6hAFZjYqhdf2iDMAk8aUhPSXOrU9rXIbnYE1MgJsR0TUTqltBn14ZJAzdkMEfZx1PtaCh2E0HjeR8N4-N8wOP0QV7_rj8MMHKlmhHgPJURRUhza3RlIzrbzLyGAgCV64RxpyEsRFrysYxHph9X1yWygwYUyUz-ER6Byj6Ko55qcIUMEDLoR9IhV87V9pFFPhhk0YBYnpQYOdsmMCkRn5ZsRElAld22IuIVAPVEMhOfSQX_Pu2exBCcUIdQ_Sglj_nfWP6_FiGSCvN3LPtD3ZNgU8TXED9PxElHZzqUBU2iSoxxLBoE8C7Vd6BpDeepDuH1jkBxb-WwzMUs7pIdnrB98BNKQgYhMEUiQZARhpyG8NeGhOoMIfXcnLDQw6XmD7PZTM6HXOSGNtIlM8jdZUiDCEBwYMwfDXOoDvGuY9MBDXaIw_uFiWa5CiU44awF1v3-EHmloFUGVQSTS1xHUjywTtC5KUsGPVPjHoShKCWUSRRLaiHVVbXLo0oGXFxuSxiIFzLUUeKa7TNtbcHpyl1aIVgpe0iVPjsCE4duOcWfN0bJeqcSEFSTU15DhJrDLlqrysEI3ssaDLrB_bSkpe3nv55Saw.m3u8
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="360p30",NAME="360p",AUTOSELECT=YES,DEFAULT=YES
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=630000,RESOLUTION=640x360,CODECS="avc1.4D401F,mp4a.40.2",VIDEO="360p30"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/CusDTjryGQpOcbZo5efDAoWz0JI__T4n7owyQCkQkw5otrJdA4MdYnrWx43dC6zmWGnNxTDEoSOJ3d4kKtPyccQc5fZCRIM0IjSJfK4fvD4VwPBf02eCrEREXqchqhiLhN_QBD163OqCAfoEbvifAqef-C9Czhy7Wy3H8kJkHXko3Yho8Mv1u5ENyjGlRaKBECbZavuTxjbkgzp_mbk60h8sYWbMFnT0xAVb3GEI59NRdd-0bvnu6eEuxJKWaEpqSrJ_m0G77afZ6yFr-aEUf92aEn_azpaFcUDs3Tt_6yub-zrQqtKluRlo25g14YZ18qJhab8FFoaRVKVzZaNZYVBLlf-5Bh8btnpNu8dg9SQe5IbHi6Wp4YSFhWK0BMO49FVdVUDSzxNFKHwiFFLr6kRMC5maVOxmvDY1bhLQjqge1yjVps82ByVasINeq9bxjkWILMRIWbOp8U_0wGXJAN_B7HE1mPYRQ7sfFaK5tQd0Qf_JVWdYZRzd9TvGJv2xgNEUCnbmNuzF2i52zwHTYoigE3YAJkT_zZb3PzWreyEGgoCd30GSfh9FOmeMnNPnb4EkSTxSYyDgDNQhSzmY1tpT9sGhDA_7biNX4vSUVka8zwfd79dTtv-jfuw3BrKxDARbW7aCSahXb7XCRU8SEOeSFUU-PulEu72Hg37qca8aDFFmPsBvds0OR-h-ig.m3u8
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="160p30",NAME="160p",AUTOSELECT=YES,DEFAULT=YES
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=230000,RESOLUTION=284x160,CODECS="avc1.4D401F,mp4a.40.2",VIDEO="160p30"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/CusDgryHl1FRa03tGi6OqC7QbH2IjFzL5P73F5_wjyigOYsZl9IQeDTCNcb3KdPYLWViVYOkblpTiWSZIurBjsLybPM5CyG8ajiQdJmcokxSWuF0JCxKW3B9k4Jzd7kjAcTG2m6Q6AgAVUl-12pmDLPiqJdS9hOmHBBz8Jfqb-nI2CQn96nHXOAv0tn9HDToE_070JGD8IdSMXM1ha8bhASa7O5ykIYR_YsGgcQ8ifWvTikPOWbRel7XAo1ABjSTbhPFhwuhdBuS2R3CcDHNqbmHLbEdQkmi9K2ibgQ9Yq7XkjziTNpFHxh2FuwWcRSgPupd82pVSJIJHAwz9Bz2rSgNnHeZBcCuJ-xa7H2DPyTrWiE915Gr4Sb5xbNMPAf2kIBP-406j3bri43AMTNJIvOOv7E33Gl93iRGdXNE18zi5Bl_mwDAX4_3SE7m10pNRYqduvqgSYBRwSwt2JRPpjzwqL8oLeOeNSGs_N6BFfbkWXT7QZ5oJgZjUFW2RBxVwPnMXuRr1kzw6BD1LrxAZbEQpqcQGKf11AfaAshyT6zKxrpyKh_oC_wl7yu4VOgYeehEezQiSgMyFLkarfOeM6I-o7Usx3jFtChwVQ0QMXq2hGWmy6LMX0d-LrUASBMkxs3Ul7uX2T3gpzqoEFgSEEddVKslKF4gxBbMMRvroOsaDKTtGcbLwO10mWlpbw.m3u8
|
||||
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="audio_only",NAME="audio_only",AUTOSELECT=NO,DEFAULT=NO
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=166907,CODECS="mp4a.40.2",VIDEO="audio_only"
|
||||
https://video-weaver.cph01.hls.ttvnw.net/v1/playlist/CvADyY7WIxbtDSJ0njAsWODtSlU3th3xEoqA4xy0hB37DMPbQ-UOcK9ipvr4PSV5JZdacS0zHw1B7M7qMxNkGTz-4GresX5omdJK25JFJ3R57TdES2QqOYr6s9Njiov9VfYboWl93cTLeDC4bOk6jWa7CROjMQOdzZQFs7ItRvKWiIOWHJWmp20pkeGJGzKn7djFb1QYrmhEWpel36muLe62rV1iXDeAw2d6wzNH0cXF-Ub09fIawnTwECXvHaQAYMK6Ij4hqdDchOVewvLJQj7vxDLMQhus6bKPbgulojTO0CLvxHdrGydswSbiYYTib_5nIIuMXTNlZbTQ1vyPJgFZlOUHPDy8znoQanX4YQnTdx-9jQ35YA2AhdKJ6edHF3oKy3c-CDxBJIJavZqsMj2Zc_o6oEUQXJfrKAlmWUaYz0FFm6j8PDRGKxpyaiUYokYZ-W0wx_sNJDKOr_Fd_MN8sRCxwiTFRWJ1ht7tumnfpP177P3n3prplM__3cgleAdVwzULqx_5bjVJYbHkcVxCE0iGz21n2UaOWkW1CaFR9QxQunEfDuiTh_w_Ver3M9kWnFpU8S0LxYtjRNlvqU8o1ds4_vgaPNFXrMaN7fAnoN1ETawu5I0yDAWIX6PclLW6K5fyjSaCiCpk3M8O5KYCTRIQqSaiIAjvvYr_qGRuzVDHrRoMJSflyQR53h9-9ZMn.m3u8
|
|
@ -88,7 +88,7 @@ use nom::{IResult};
|
|||
use nom::{ delimited,none_of,peek,is_a,is_not,complete,terminated,tag,
|
||||
alt,do_parse,opt,named,map,map_res,eof,many0,take,take_until,char};
|
||||
use nom::combinator::map;
|
||||
use nom::character::complete::{line_ending};
|
||||
use nom::character::complete::{line_ending, not_line_ending};
|
||||
use std::str;
|
||||
use std::f32;
|
||||
use std::string;
|
||||
|
@ -514,8 +514,8 @@ named!(pub unquoted<String>,
|
|||
|
||||
named!(pub consume_line<String>,
|
||||
do_parse!(
|
||||
line: map_res!(is_not!("\r\n"), from_utf8_slice)
|
||||
>> line_ending
|
||||
line: map_res!(not_line_ending, from_utf8_slice)
|
||||
>> opt!(line_ending)
|
||||
>> (line)
|
||||
)
|
||||
);
|
||||
|
|
12
tests/lib.rs
12
tests/lib.rs
|
@ -86,6 +86,11 @@ fn playlist_not_ending_in_newline_master() {
|
|||
assert!(print_parse_playlist_test("master-not-ending-in-newline.m3u8"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn playlist_not_ending_in_newline_master1() {
|
||||
assert!(print_parse_playlist_test("master-not-ending-in-newline-1.m3u8"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn playlist_not_ending_in_newline_media() {
|
||||
assert!(print_parse_playlist_test("media-not-ending-in-newline.m3u8"));
|
||||
|
@ -201,10 +206,9 @@ fn quotes() {
|
|||
|
||||
#[test]
|
||||
fn consume_line_empty() {
|
||||
assert_eq!(
|
||||
consume_line(b"\r\nrest"),
|
||||
Result::Err(nom::Err::Error(("\r\nrest".as_bytes(), nom::error::ErrorKind::IsNot)))
|
||||
);
|
||||
let expected = Result::Ok(("rest".as_bytes(), "".to_string()));
|
||||
let actual = consume_line(b"\r\nrest");
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue