Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
0fd33223
Commit
0fd33223
authored
Sep 15, 2005
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hopefully "The Right Fix" patch for M3U parsing, by Daniel Straenger.
parent
c453158b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
82 deletions
+67
-82
modules/demux/m3u.c
modules/demux/m3u.c
+1
-1
modules/demux/playlist/m3u.c
modules/demux/playlist/m3u.c
+54
-43
modules/misc/playlist/m3u.c
modules/misc/playlist/m3u.c
+12
-38
No files found.
modules/demux/m3u.c
View file @
0fd33223
...
...
@@ -127,7 +127,7 @@ static int Activate( vlc_object_t * p_this )
if
(
i_type
!=
TYPE_M3U
)
{
char
*
p_peek
;
int
i_size
=
stream_Peek
(
p_demux
->
s
,
(
uint8_t
*
)
&
p_peek
,
MAX_LINE
);
int
i_size
=
stream_Peek
(
p_demux
->
s
,
(
uint8_t
*
*
)
&
p_peek
,
MAX_LINE
);
i_size
-=
sizeof
(
"[Reference]"
)
-
1
;
if
(
i_size
>
0
)
...
...
modules/demux/playlist/m3u.c
View file @
0fd33223
...
...
@@ -44,7 +44,7 @@ struct demux_sys_t
*****************************************************************************/
static
int
Demux
(
demux_t
*
p_demux
);
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
);
static
void
parseEXTINF
(
char
*
psz_string
,
char
**
ppsz_a
uthor
,
char
**
ppsz_name
,
int
*
pi_duration
);
static
void
parseEXTINF
(
char
*
psz_string
,
char
**
ppsz_a
rtist
,
char
**
ppsz_name
,
int
*
pi_duration
);
/*****************************************************************************
* Import_M3U: main import function
...
...
@@ -110,7 +110,7 @@ static int Demux( demux_t *p_demux )
char
*
psz_line
;
char
*
psz_name
=
NULL
;
char
*
psz_a
uthor
=
NULL
;
char
*
psz_a
rtist
=
NULL
;
int
i_parsed_duration
=
0
;
mtime_t
i_duration
=
-
1
;
char
**
ppsz_options
=
NULL
;
...
...
@@ -159,17 +159,16 @@ static int Demux( demux_t *p_demux )
{
/* Extended info */
psz_parse
+=
sizeof
(
"EXTINF:"
)
-
1
;
parseEXTINF
(
psz_parse
,
&
psz_a
uthor
,
&
psz_name
,
&
i_parsed_duration
);
if
(
i_parsed_duration
>=
0
)
parseEXTINF
(
psz_parse
,
&
psz_a
rtist
,
&
psz_name
,
&
i_parsed_duration
);
if
(
i_parsed_duration
>=
0
)
i_duration
=
i_parsed_duration
*
1000000
;
if
(
psz_name
)
psz_name
=
strdup
(
psz_name
);
if
(
psz_a
uthor
)
psz_a
uthor
=
strdup
(
psz_author
);
if
(
psz_a
rtist
)
psz_a
rtist
=
strdup
(
psz_artist
);
}
else
if
(
!
strncasecmp
(
psz_parse
,
"EXTVLCOPT:"
,
sizeof
(
"EXTVLCOPT:"
)
-
1
)
)
{
/* VLC Option */
char
*
psz_option
;
...
...
@@ -206,9 +205,9 @@ static int Demux( demux_t *p_demux )
playlist_ItemAddOption
(
p_item
,
ppsz_options
[
i
]
);
}
p_item
->
input
.
i_duration
=
i_duration
;
if
(
psz_a
uthor
)
if
(
psz_a
rtist
&&
*
psz_artist
)
vlc_input_item_AddInfo
(
&
p_item
->
input
,
_
(
"Meta-information"
),
_
(
"Artist"
),
"%s"
,
psz_a
uthor
);
_
(
"Artist"
),
"%s"
,
psz_a
rtist
);
playlist_NodeAddItem
(
p_playlist
,
p_item
,
p_current
->
pp_parents
[
0
]
->
i_view
,
p_current
,
PLAYLIST_APPEND
,
...
...
@@ -239,8 +238,8 @@ static int Demux( demux_t *p_demux )
ppsz_options
=
NULL
;
i_options
=
0
;
if
(
psz_name
)
free
(
psz_name
);
psz_name
=
NULL
;
if
(
psz_a
uthor
)
free
(
psz_author
);
psz_a
uthor
=
NULL
;
if
(
psz_a
rtist
)
free
(
psz_artist
);
psz_a
rtist
=
NULL
;
i_parsed_duration
=
0
;
i_duration
=
-
1
;
...
...
@@ -267,58 +266,70 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return
VLC_EGENERIC
;
}
static
void
parseEXTINF
(
char
*
psz_string
,
char
**
ppsz_a
uthor
,
static
void
parseEXTINF
(
char
*
psz_string
,
char
**
ppsz_a
rtist
,
char
**
ppsz_name
,
int
*
pi_duration
)
{
char
*
end
=
NULL
;
char
*
end
=
NULL
;
char
*
psz_item
=
NULL
;
char
*
psz_duration
=
NULL
;
char
*
pos
;
end
=
psz_string
+
strlen
(
psz_string
);
/* ignore whitespaces */
for
(;
psz_string
<
end
&&
(
*
psz_string
==
'\t'
||
*
psz_string
==
' '
);
for
(;
psz_string
<
end
&&
(
*
psz_string
==
'\t'
||
*
psz_string
==
' '
);
psz_string
++
);
/*
read all digits
*/
/*
duration: read to next comma
*/
psz_item
=
psz_string
;
psz_
duration
=
strchr
(
psz_string
,
','
);
if
(
psz_duration
)
psz_
string
=
strchr
(
psz_string
,
','
);
if
(
psz_string
)
{
*
psz_duration
=
'\0'
;
*
pi_duration
=
atoi
(
psz_item
);
psz_string
=
psz_duration
;
*
psz_string
=
'\0'
;
*
pi_duration
=
atoi
(
psz_item
);
}
if
(
psz_string
<
end
)
/* continue parsing if possible */
else
{
psz_string
++
;
return
;
}
/* read the author */
/* parse the author until unescaped comma is reached */
psz_item
=
pos
=
psz_string
;
while
(
psz_string
<
end
&&
*
psz_string
!=
','
)
{
if
(
*
psz_string
==
'\\'
)
psz_string
++
;
/* Skip escape character */
*
pos
++
=
*
psz_string
++
;
}
*
pos
=
'\0'
;
/* terminate the item */
*
ppsz_author
=
psz_item
;
if
(
psz_string
<
end
)
/* continue parsing if possible */
psz_string
++
;
/* analyse the remaining string */
psz_item
=
strstr
(
psz_string
,
" - "
);
if
(
psz_string
<
end
)
/* continue parsing if possible */
/* here we have the 0.8.2+ format with artist */
if
(
psz_item
)
{
/* *** "EXTINF:time,artist - name" */
*
psz_item
=
'\0'
;
*
ppsz_artist
=
psz_string
;
*
ppsz_name
=
psz_item
+
3
;
/* points directly after ' - ' */
return
;
}
/* reaching this point means: 0.8.1- with artist or something without artist */
if
(
*
psz_string
==
','
)
{
/* *** "EXTINF:time,,name" */
psz_string
++
;
/* the title doesn't need to be escaped */
*
ppsz_name
=
psz_string
;
*
ppsz_name
=
psz_string
;
return
;
}
if
(
!**
ppsz_name
)
psz_item
=
psz_string
;
psz_string
=
strchr
(
psz_string
,
','
);
if
(
psz_string
)
{
/* Assume a syntax without author name */
*
ppsz_name
=
*
ppsz_author
;
*
ppsz_author
=
NULL
;
/* *** "EXTINF:time,artist,name" */
*
psz_string
=
'\0'
;
*
ppsz_artist
=
psz_item
;
*
ppsz_name
=
psz_string
+
1
;
}
else
{
/* *** "EXTINF:time,name" */
*
ppsz_name
=
psz_item
;
}
return
;
}
modules/misc/playlist/m3u.c
View file @
0fd33223
...
...
@@ -63,52 +63,26 @@ int Export_M3U( vlc_object_t *p_this )
strcmp
(
p_playlist
->
pp_items
[
i
]
->
input
.
psz_name
,
p_playlist
->
pp_items
[
i
]
->
input
.
psz_uri
)
)
{
char
*
psz_a
uthor
=
vlc_input_item_GetInfo
(
&
p_playlist
->
pp_items
[
i
]
->
input
,
_
(
"Meta-information"
),
_
(
"Artist"
)
);
if
(
psz_a
uthor
&&
*
psz_author
)
char
*
psz_a
rtist
=
vlc_input_item_GetInfo
(
&
p_playlist
->
pp_items
[
i
]
->
input
,
_
(
"Meta-information"
),
_
(
"Artist"
)
);
if
(
psz_a
rtist
&&
*
psz_artist
)
{
/* the author must be escaped if it contains a comma */
char
*
p_src
;
short
i_cnt
;
/* so count the commas or backslash */
for
(
i_cnt
=
0
,
p_src
=
psz_author
;
*
p_src
;
p_src
++
)
if
(
*
p_src
==
','
||
*
p_src
==
'\\'
)
i_cnt
++
;
/* Is there a comma ? */
if
(
i_cnt
)
{
char
*
psz_escaped
=
NULL
;
char
*
p_dst
;
psz_escaped
=
(
char
*
)
malloc
(
(
strlen
(
psz_author
)
+
i_cnt
+
1
)
*
sizeof
(
char
)
);
if
(
!
psz_escaped
)
return
VLC_ENOMEM
;
/* copy the string and escape every comma with backslash */
for
(
p_src
=
psz_author
,
p_dst
=
psz_escaped
;
*
p_src
;
p_src
++
,
p_dst
++
)
{
if
(
*
p_src
==
','
||
*
p_src
==
'\\'
)
*
p_dst
++
=
'\\'
;
*
p_dst
=
*
p_src
;
}
*
p_dst
=
'\0'
;
free
(
psz_author
);
psz_author
=
psz_escaped
;
}
fprintf
(
p_export
->
p_file
,
"#EXTINF:%i,%s,%s
\n
"
,
(
int
)(
p_playlist
->
pp_items
[
i
]
->
input
.
i_duration
/
1000000
),
psz_author
,
/* write EXTINF with artist */
fprintf
(
p_export
->
p_file
,
"#EXTINF:%i,%s - %s
\n
"
,
(
int
)(
p_playlist
->
pp_items
[
i
]
->
input
.
i_duration
/
1000000
),
psz_artist
,
p_playlist
->
pp_items
[
i
]
->
input
.
psz_name
);
}
else
{
/* write EXTINF without a
uthor
*/
fprintf
(
p_export
->
p_file
,
"#EXTINF:%i,
,
%s
\n
"
,
/* write EXTINF without a
rtist
*/
fprintf
(
p_export
->
p_file
,
"#EXTINF:%i,%s
\n
"
,
(
int
)(
p_playlist
->
pp_items
[
i
]
->
input
.
i_duration
/
1000000
),
p_playlist
->
pp_items
[
i
]
->
input
.
psz_name
);
}
if
(
psz_a
uthor
)
free
(
psz_a
uthor
);
if
(
psz_a
rtist
)
free
(
psz_a
rtist
);
}
/* VLC specific options */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment