add channels filter
add hardcoded discovery science channel
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
<TextBlock FontSize="15" Foreground="White" Text="Ch" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
<TextBlock FontSize="15" Foreground="White" Text="Ch" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
<Button Grid.RowSpan="2" Height="70" Width="50" Margin="10,0,10,0" Style="{DynamicResource ButtonUp}" Command="{Binding NextCommand}" />
|
<Button Grid.RowSpan="2" Height="70" Width="50" Margin="10,0,10,0" Style="{DynamicResource ButtonUp}" Command="{Binding NextCommand}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Grid Grid.Column="1" x:Name="programInfo" Visibility="{Binding IsProgramInfoVisible,Converter={StaticResource BooleanToVisibilityConverterKey}}">
|
<Grid Grid.Column="1" x:Name="programInfo" Visibility="{Binding IsProgramInfoVisible,Converter={StaticResource BooleanToVisibilityConverterKey}}" Background="#0F000000">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Net.Http;
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
@@ -114,8 +115,16 @@ namespace TV_Player
|
|||||||
|
|
||||||
public static async Task<(List<M3UInfo> programList, string programGuide)> DownloadM3UFromWebAsync(string url)
|
public static async Task<(List<M3UInfo> programList, string programGuide)> DownloadM3UFromWebAsync(string url)
|
||||||
{
|
{
|
||||||
var fileData=await ReadFile(url);
|
string fileData;
|
||||||
// Parse M3U content
|
if (Uri.IsWellFormedUriString(url,UriKind.Absolute))
|
||||||
|
{
|
||||||
|
fileData = await ReadFile(url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileData= File.ReadAllText(url);
|
||||||
|
}
|
||||||
|
|
||||||
return ParseM3UFromString(fileData);
|
return ParseM3UFromString(fileData);
|
||||||
}
|
}
|
||||||
private static string[] SplitStringBeforeSeparator(string input, string separator)
|
private static string[] SplitStringBeforeSeparator(string input, string separator)
|
||||||
@@ -170,7 +179,8 @@ namespace TV_Player
|
|||||||
private static bool TryParseM3ULine(string m3uLine, out M3UInfo? info)
|
private static bool TryParseM3ULine(string m3uLine, out M3UInfo? info)
|
||||||
{
|
{
|
||||||
info = null;
|
info = null;
|
||||||
string pattern = @"#EXTINF:\d+ CUID=""(?<CUID>.*?)"" number=""(?<Number>.*?)"" tvg-id=""(?<TvgID>.*?)"" tvg-name=""(?<TvgName>.*?)"".*?tvg-logo=""(?<Logo>.*?)"" group-title=""(?<GroupTitle>.*?)""[^,]*,(?<Name>.*)[^\r](?<URL>.*)$";
|
//string pattern = @"#EXTINF:\d+ CUID=""(?<CUID>.*?)"" number=""(?<Number>.*?)"" tvg-id=""(?<TvgID>.*?)"" tvg-name=""(?<TvgName>.*?)"".*?tvg-logo=""(?<Logo>.*?)"" group-title=""(?<GroupTitle>.*?)""[^,]*,(?<Name>.*)[^\r](?<URL>.*)$";
|
||||||
|
string pattern = @"#EXTINF:(?:-?\d+)\s+?(?:CUID=""(?<CUID>.*?)""\s+)?(?:number=""(?<Number>.*?)""\s+)?(?:tvg-id=""(?<TvgID>.*?)""\s+)?(?:tvg-name=""(?<TvgName>.*?)""\s+)?(?:tvg-logo=""(?<Logo>.*?)""\s+)?(?:group-title=""(?<GroupTitle>.*?)"")[^,]*,(?<Name>.*)[^\r](?<URL>.*)$";
|
||||||
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
|
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
Match match = regex.Match(m3uLine);
|
Match match = regex.Match(m3uLine);
|
||||||
|
|||||||
@@ -19,7 +19,18 @@ namespace TV_Player
|
|||||||
{
|
{
|
||||||
//string m3uLink = "http://pl.da-tv.vip/a71e77fa/835b3216/tv.m3u";
|
//string m3uLink = "http://pl.da-tv.vip/a71e77fa/835b3216/tv.m3u";
|
||||||
var result = await M3UParser.DownloadM3UFromWebAsync(m3uLink);
|
var result = await M3UParser.DownloadM3UFromWebAsync(m3uLink);
|
||||||
|
|
||||||
|
|
||||||
|
// For how hardcoded add custom channel
|
||||||
|
result.programList.Add(new M3UInfo()
|
||||||
|
{
|
||||||
|
GroupTitle = "Познавательные",
|
||||||
|
Name = "Discovery science",
|
||||||
|
Logo = "http://ip.viks.tv/posts/2018-11/1543603622_discovery_science.png",
|
||||||
|
Number = Convert.ToString(result.programList.Count+1),
|
||||||
|
Url= "https://s2.viks.tv/571/index.m3u8?k=1715093638p791i991i86i78S9b9c0d8fefdcO74ff3ed2f4710c95b07"
|
||||||
|
});;
|
||||||
|
|
||||||
programsSubject.OnNext(result.programList);
|
programsSubject.OnNext(result.programList);
|
||||||
|
|
||||||
var groupping = result.programList.GroupBy(item => item.GroupTitle)
|
var groupping = result.programList.GroupBy(item => item.GroupTitle)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace TV_Player
|
|||||||
public class ProgramsGroupViewModel : ObservableViewModelBase, IDisposable
|
public class ProgramsGroupViewModel : ObservableViewModelBase, IDisposable
|
||||||
{
|
{
|
||||||
private List<GroupInfo> _programs;
|
private List<GroupInfo> _programs;
|
||||||
|
|
||||||
public List<GroupInfo> Programs
|
public List<GroupInfo> Programs
|
||||||
{
|
{
|
||||||
get => _programs;
|
get => _programs;
|
||||||
@@ -20,7 +21,7 @@ namespace TV_Player
|
|||||||
public ProgramsGroupViewModel()
|
public ProgramsGroupViewModel()
|
||||||
{
|
{
|
||||||
ItemSelectedCommand = new RelayCommand(OnItemSelected);
|
ItemSelectedCommand = new RelayCommand(OnItemSelected);
|
||||||
_groupInformationSubscriber = TVPlayerViewModel.Instance.PlaylistData.GroupsInformation.Subscribe(x=>Programs = x);
|
_groupInformationSubscriber = TVPlayerViewModel.Instance.PlaylistData.GroupsInformation.Subscribe(x => Programs = SettingsModel.HiddenGroups == null ? x : x.Where(g => !SettingsModel.HiddenGroups.Contains(g.Name.ToLower())).ToList());
|
||||||
|
|
||||||
TVPlayerViewModel.Instance.TopPanelVisible(true, "Группы");
|
TVPlayerViewModel.Instance.TopPanelVisible(true, "Группы");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace TV_Player.ViewModels
|
|||||||
public static string LastScreen { get; set; }
|
public static string LastScreen { get; set; }
|
||||||
public static GroupInfo Group { get; set; }
|
public static GroupInfo Group { get; set; }
|
||||||
public static M3UInfo Program { get; set; }
|
public static M3UInfo Program { get; set; }
|
||||||
|
public static string[] HiddenGroups { get; set; }
|
||||||
|
|
||||||
public static void SaveSetttings()
|
public static void SaveSetttings()
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,8 @@ namespace TV_Player.ViewModels
|
|||||||
StartFullScreen,
|
StartFullScreen,
|
||||||
LastScreen,
|
LastScreen,
|
||||||
Group,
|
Group,
|
||||||
Program
|
Program,
|
||||||
|
HiddenGroups,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Serialize the object to JSON
|
// Serialize the object to JSON
|
||||||
@@ -47,7 +48,8 @@ namespace TV_Player.ViewModels
|
|||||||
Group = default(GroupInfo),
|
Group = default(GroupInfo),
|
||||||
Program = default(M3UInfo),
|
Program = default(M3UInfo),
|
||||||
StartFromLastScreen = default(bool),
|
StartFromLastScreen = default(bool),
|
||||||
StartFullScreen = default(bool)
|
StartFullScreen = default(bool),
|
||||||
|
HiddenGroups = default(string[])
|
||||||
};
|
};
|
||||||
if (File.Exists(SettingsFilePath))
|
if (File.Exists(SettingsFilePath))
|
||||||
{
|
{
|
||||||
@@ -62,6 +64,7 @@ namespace TV_Player.ViewModels
|
|||||||
Program = loadedData.Program;
|
Program = loadedData.Program;
|
||||||
StartFromLastScreen = loadedData.StartFromLastScreen;
|
StartFromLastScreen = loadedData.StartFromLastScreen;
|
||||||
StartFullScreen = loadedData.StartFullScreen;
|
StartFullScreen = loadedData.StartFullScreen;
|
||||||
|
HiddenGroups = loadedData.HiddenGroups;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}"
|
"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}"
|
||||||
"IsWebType" = "8:FALSE"
|
"IsWebType" = "8:FALSE"
|
||||||
"ProjectName" = "8:TVPlayerSetup"
|
"ProjectName" = "8:TVPlayerSetup"
|
||||||
"LanguageId" = "3:1049"
|
"LanguageId" = "3:0"
|
||||||
"CodePage" = "3:1251"
|
"CodePage" = "3:1252"
|
||||||
"UILanguageId" = "3:1049"
|
"UILanguageId" = "3:0"
|
||||||
"SccProjectName" = "8:"
|
"SccProjectName" = "8:"
|
||||||
"SccLocalPath" = "8:"
|
"SccLocalPath" = "8:"
|
||||||
"SccAuxPath" = "8:"
|
"SccAuxPath" = "8:"
|
||||||
@@ -13416,7 +13416,7 @@
|
|||||||
}
|
}
|
||||||
"MsiBootstrapper"
|
"MsiBootstrapper"
|
||||||
{
|
{
|
||||||
"LangId" = "3:1049"
|
"LangId" = "3:0"
|
||||||
"RequiresElevation" = "11:FALSE"
|
"RequiresElevation" = "11:FALSE"
|
||||||
}
|
}
|
||||||
"Product"
|
"Product"
|
||||||
@@ -13424,7 +13424,7 @@
|
|||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:TVPlayerSetup"
|
"ProductName" = "8:TVPlayerSetup"
|
||||||
"ProductCode" = "8:{9C9771D7-D3C6-49DD-9F5C-1B99F0808FE6}"
|
"ProductCode" = "8:{9C9771D7-D3C6-49DD-9F5C-1B99F0808FE6}"
|
||||||
"PackageCode" = "8:{17F7FB4A-FCDB-42DC-AD6F-5B58EF7FC484}"
|
"PackageCode" = "8:{734B0943-71FD-40D7-A9FC-97A7146D90CF}"
|
||||||
"UpgradeCode" = "8:{659EC3EB-443A-41ED-BD14-696FEBD8DDBF}"
|
"UpgradeCode" = "8:{659EC3EB-443A-41ED-BD14-696FEBD8DDBF}"
|
||||||
"AspNetVersion" = "8:2.0.50727.0"
|
"AspNetVersion" = "8:2.0.50727.0"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
|
|||||||
Reference in New Issue
Block a user