From: Duncan W. <du...@fr...> - 2008-01-23 20:10:43
|
Author: duncan Date: Wed Jan 23 15:10:40 2008 New Revision: 10307 Log: [ 1872465 ] m3u parsing error Fix applied to check for urls and to chdir first Modified: branches/rel-1-7/freevo/ChangeLog branches/rel-1-7/freevo/src/playlist.py branches/rel-1/freevo/ChangeLog branches/rel-1/freevo/src/playlist.py Modified: branches/rel-1-7/freevo/ChangeLog ============================================================================== --- branches/rel-1-7/freevo/ChangeLog (original) +++ branches/rel-1-7/freevo/ChangeLog Wed Jan 23 15:10:40 2008 @@ -36,7 +36,8 @@ * Updated xine video plug-in to show OSD messages (F#1861770) * Deleted plug-in weather, moved to contrib/plugins (F#1863476) * Fixed apple trailers plug-in crashing (B#1861463) - * Fixed audio playlists when the the fxd file contains utf-8 characters (B#1865272) + * Fixed audio play lists when the fxd file contains utf-8 characters (B#1865272) + * Fixed audio play lists when the fxd file contains absolute paths and urls (B#1872465) * Fixed audio cdbackup not showing the alert message when there is no data from freedb (B#1869928) * Fixed manual record tv plug-in to work in December (B#1858008) * Fixed oneclick weather plug-in to allow non-ascii location names (B#1856597) Modified: branches/rel-1-7/freevo/src/playlist.py ============================================================================== --- branches/rel-1-7/freevo/src/playlist.py (original) +++ branches/rel-1-7/freevo/src/playlist.py Wed Jan 23 15:10:40 2008 @@ -90,8 +90,8 @@ """ This is the (m3u) playlist reading function. - Arguments: plsname - the playlist filename - Returns: The list of interesting lines in the playlist + @param plsname: The playlist filename + @returns: The list of interesting lines in the playlist """ try: lines = util.readfile(plsname) @@ -107,11 +107,19 @@ return 0 (curdir, playlistname) = os.path.split(plsname) + #XXX this may not work if the curdir is not accessible + os.chdir(curdir) for line in playlist_lines: line = line.replace('\\', '/') # Fix MSDOS slashes try: - if os.path.exists(os.path.abspath(line)): - self.playlist.append(os.path.abspath(line)) + if line.find('://') > 0: + self.playlist.append(line) + elif os.path.isabs(line): + if os.path.exists(line): + self.playlist.append(line) + else: + if os.path.exists(os.path.abspath(os.path.join(curdir, line))): + self.playlist.append(os.path.abspath(os.path.join(curdir, line))) except TypeError: print 'Bad m3u playlist line in "%s":%r' % (plsname, line) @@ -139,11 +147,18 @@ line[numchars:] (curdir, playlistname) = os.path.split(plsname) + os.chdir(curdir) for line in playlist_lines: if line.endswith('\r\n'): line = line.replace('\\', '/') # Fix MSDOS slashes - if os.path.exists(os.path.abspath(line)): - self.playlist.append(os.path.abspath(line)) + if line.find('://') > 0: + self.playlist.append(line) + elif os.path.isabs(line): + if os.path.exists(line): + self.playlist.append(line) + else: + if os.path.exists(os.path.abspath(os.path.join(curdir, line))): + self.playlist.append(os.path.abspath(os.path.join(curdir, line))) @@ -162,6 +177,7 @@ """ (curdir, playlistname) = os.path.split(ssrname) + os.chdir(curdir) out_lines = [] try: lines = util.readfile(ssrname) @@ -173,15 +189,12 @@ playlist_lines = filter(lambda l: l[0] != '#', lines) - """ - Here's where we parse the line. See the format above. - TODO: Make the search case insensitive - """ + # Here's where we parse the line. See the format above. for line in playlist_lines: tmp_list = [] - ss_name = re.findall('FileName: \"(.*?)\"', line) - ss_caption = re.findall('Caption: \"(.*?)\"', line) - ss_delay = re.findall('Delay: \"(.*?)\"', line) + ss_name = re.findall('FileName: \"(.*?)\"', line, re.I) + ss_caption = re.findall('Caption: \"(.*?)\"', line, re.I) + ss_delay = re.findall('Delay: \"(.*?)\"', line, re.I) if ss_name != []: if ss_caption == []: @@ -190,7 +203,11 @@ ss_delay += [5] for p in self.get_plugins: - for i in p.get(self, [os.path.abspath(ss_name[0])]): + if os.path.isabs(ss_name[0]): + curdir = ss_name[0] + else: + curdir = os.path.abspath(os.path.join(curdir, ss_name[0])) + for i in p.get(self, [curdir]): if i.type == 'image': i.name = Unicode(ss_caption[0]) i.duration = int(ss_delay[0]) Modified: branches/rel-1/freevo/ChangeLog ============================================================================== --- branches/rel-1/freevo/ChangeLog (original) +++ branches/rel-1/freevo/ChangeLog Wed Jan 23 15:10:40 2008 @@ -41,7 +41,8 @@ * Updated xine video plug-in to show OSD messages (F#1861770) * Deleted plug-in weather, moved to contrib/plugins (F#1863476) * Fixed apple trailers plug-in crashing (B#1861463) - * Fixed audio playlists when the the fxd file contains utf-8 characters (B#1865272) + * Fixed audio play lists when the fxd file contains utf-8 characters (B#1865272) + * Fixed audio play lists when the fxd file contains absolute paths and urls (B#1872465) * Fixed audio cdbackup not showing the alert message when there is no data from freedb (B#1869928) * Fixed manual record tv plug-in to work in December (B#1858008) * Fixed oneclick weather plug-in to allow non-ascii location names (B#1856597) Modified: branches/rel-1/freevo/src/playlist.py ============================================================================== --- branches/rel-1/freevo/src/playlist.py (original) +++ branches/rel-1/freevo/src/playlist.py Wed Jan 23 15:10:40 2008 @@ -90,8 +90,8 @@ """ This is the (m3u) playlist reading function. - Arguments: plsname - the playlist filename - Returns: The list of interesting lines in the playlist + @param plsname: The playlist filename + @returns: The list of interesting lines in the playlist """ try: lines = util.readfile(plsname) @@ -107,11 +107,19 @@ return 0 (curdir, playlistname) = os.path.split(plsname) + #XXX this may not work if the curdir is not accessible + os.chdir(curdir) for line in playlist_lines: line = line.replace('\\', '/') # Fix MSDOS slashes try: - if os.path.exists(os.path.abspath(line)): - self.playlist.append(os.path.abspath(line)) + if line.find('://') > 0: + self.playlist.append(line) + elif os.path.isabs(line): + if os.path.exists(line): + self.playlist.append(line) + else: + if os.path.exists(os.path.abspath(os.path.join(curdir, line))): + self.playlist.append(os.path.abspath(os.path.join(curdir, line))) except TypeError: print 'Bad m3u playlist line in "%s":%r' % (plsname, line) @@ -139,11 +147,18 @@ line[numchars:] (curdir, playlistname) = os.path.split(plsname) + os.chdir(curdir) for line in playlist_lines: if line.endswith('\r\n'): line = line.replace('\\', '/') # Fix MSDOS slashes - if os.path.exists(os.path.abspath(line)): - self.playlist.append(os.path.abspath(line)) + if line.find('://') > 0: + self.playlist.append(line) + elif os.path.isabs(line): + if os.path.exists(line): + self.playlist.append(line) + else: + if os.path.exists(os.path.abspath(os.path.join(curdir, line))): + self.playlist.append(os.path.abspath(os.path.join(curdir, line))) @@ -162,6 +177,7 @@ """ (curdir, playlistname) = os.path.split(ssrname) + os.chdir(curdir) out_lines = [] try: lines = util.readfile(ssrname) @@ -173,15 +189,12 @@ playlist_lines = filter(lambda l: l[0] != '#', lines) - """ - Here's where we parse the line. See the format above. - TODO: Make the search case insensitive - """ + # Here's where we parse the line. See the format above. for line in playlist_lines: tmp_list = [] - ss_name = re.findall('FileName: \"(.*?)\"', line) - ss_caption = re.findall('Caption: \"(.*?)\"', line) - ss_delay = re.findall('Delay: \"(.*?)\"', line) + ss_name = re.findall('FileName: \"(.*?)\"', line, re.I) + ss_caption = re.findall('Caption: \"(.*?)\"', line, re.I) + ss_delay = re.findall('Delay: \"(.*?)\"', line, re.I) if ss_name != []: if ss_caption == []: @@ -190,7 +203,11 @@ ss_delay += [5] for p in self.get_plugins: - for i in p.get(self, [os.path.abspath(ss_name[0])]): + if os.path.isabs(ss_name[0]): + curdir = ss_name[0] + else: + curdir = os.path.abspath(os.path.join(curdir, ss_name[0])) + for i in p.get(self, [curdir]): if i.type == 'image': i.name = Unicode(ss_caption[0]) i.duration = int(ss_delay[0]) |