Skip to content

Commit

Permalink
Fixed MP1-5236: Add support for m3u8 files
Browse files Browse the repository at this point in the history
  • Loading branch information
doskabouter committed Feb 16, 2025
1 parent 5b235f1 commit ef11fb0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PlayListFactory
public static IPlayListIO CreateIO(string fileName)
{
string extension = GetLowerCaseExtension(fileName);
if (extension == ".m3u")
if (extension == ".m3u" || extension == ".m3u8")
{
return new PlayListM3uIO();
}
Expand Down Expand Up @@ -58,7 +58,7 @@ private static string GetLowerCaseExtension(string fileName)
public static bool IsPlayList(string fileName)
{
string extension = GetLowerCaseExtension(fileName);
if (extension == ".m3u")
if (extension == ".m3u" || extension == ".m3u8")
return true;
if (extension == ".pls")
return true;
Expand Down
13 changes: 5 additions & 8 deletions TvEngine3/TVLibrary/SetupTv/PlaylistSupport/PlayListM3uIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.IO;
using SetupTv;
using System.Text;
using System.Text.RegularExpressions;

namespace MediaPortal.Playlists
{
Expand Down Expand Up @@ -102,15 +103,11 @@ public bool Load(PlayList incomingPlaylist, string playlistFileName)
private static bool ExtractM3uInfo(string trimmedLine, ref string songName, ref int lDuration)
{
//bool successfull;
int iColon = trimmedLine.IndexOf(":");
int iComma = trimmedLine.IndexOf(",");
if (iColon >= 0 && iComma >= 0 && iComma > iColon)
var match = Regex.Match(trimmedLine, @"#EXTINF:(?<duration>-?\d+)(?<attributes>.*),(?<title>.+)");
if (match.Success)
{
iColon++;
string duration = trimmedLine.Substring(iColon, iComma - iColon);
iComma++;
songName = trimmedLine.Substring(iComma);
lDuration = Int32.Parse(duration);
lDuration = Int32.Parse(match.Groups["duration"].Value);
songName = match.Groups["title"].Value.Trim();
return true;
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions TvEngine3/TVLibrary/SetupTv/Sections/CardDvbIP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ private void Init()
String tuningFolder = String.Format(@"{0}\TuningParameters\dvbip", PathManager.GetDataPath);
if (Directory.Exists(tuningFolder))
{
string[] files = Directory.GetFiles(tuningFolder, "*.m3u");
string[] files = Directory.GetFiles(tuningFolder, "*.m3u*");
foreach (string f in files)
{
mpComboBoxService.Items.Add(Path.GetFileNameWithoutExtension(f));
mpComboBoxService.Items.Add(Path.GetFileName(f));
}
}
mpComboBoxService.SelectedIndex = 0;
Expand Down Expand Up @@ -169,10 +169,10 @@ private void DoScan()
else
{
IPlayListIO playlistIO =
PlayListFactory.CreateIO(String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath,
PlayListFactory.CreateIO(String.Format(@"{0}\TuningParameters\dvbip\{1}", PathManager.GetDataPath,
mpComboBoxService.SelectedItem));
playlistIO.Load(playlist,
String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath,
String.Format(@"{0}\TuningParameters\dvbip\{1}", PathManager.GetDataPath,
mpComboBoxService.SelectedItem));
}
if (playlist.Count == 0) return;
Expand Down

0 comments on commit ef11fb0

Please sign in to comment.