Skip to content

Commit

Permalink
add script LOAD
Browse files Browse the repository at this point in the history
  • Loading branch information
dav1977 committed Feb 5, 2018
1 parent de00bb9 commit e73a75c
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 30 deletions.
5 changes: 4 additions & 1 deletion IPTVmanager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,21 @@ public partial class App : Application
private void Application_Startup(object sender, StartupEventArgs e)
{
if (Model.loc.start_one) return;
if (Model.data.arguments_startup == null) Model.data.arguments_startup = new string[100];

try
{
byte i = 0;
foreach (string arg in e.Args)
{
if (Model.data.arguments_startup == null) Model.data.arguments_startup = new string[100];
Model.data.arguments_startup[i] = arg;
if (i > 90) break;
}
}
catch { }

//test
//Model.data.arguments_startup[0] = "radio.m3u";
}
}

Expand Down
14 changes: 14 additions & 0 deletions IPTVmanager/Model/ModeWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ public static class ModeWork
/// </summary>
public static bool skip_obrez_skobki = false;

/// <summary>
/// Добавить файл
/// </summary>
public static bool add = false;
public static string addpath = "";
/// <summary>
/// Добавить файл ИДЕТ ПРОЦЕСС ДОБАВЛЕНИЯ
/// </summary>
public static bool process_adding = false;
/// <summary>
/// флаг события добавления
/// </summary>
public static bool flag_add = false;

//---------------------------------------------
public static bool OpenWindow_db_update = false;
public static bool OpenWindow_radio = false;
public static bool OpenWindow_db_updateREADY = false;
Expand Down
63 changes: 48 additions & 15 deletions IPTVmanager/UserClass/FileWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
using System.Text.RegularExpressions;
using Microsoft.Win32;
using System.Net;
using System.Reflection;

namespace IPTVman.ViewModel
{
class FileWork
{
//public static string pathAppication = Environment.ExpandEnvironmentVariables(@"%APPDATA%\IPTVmanager");

public static event Action<typefilter> Event_UpdateLIST;

readonly string tempname = "temp_m3u_IPTVmanager";
Expand All @@ -43,6 +46,16 @@ class FileWork

const uint PROCESS_TERMINATE = 0x1;

public static string Get_ApplPath()
{
string path = "";
path = System.Reflection.Assembly.GetExecutingAssembly().Location ;
path = path.Replace(@"\", @"/");
path = path.Replace(@"IPTVmanager.exe", @"");
return path;
}


private static void TerminateProcess(IntPtr PID)
{
IntPtr hProcess = OpenProcess(PROCESS_TERMINATE, false, PID);
Expand Down Expand Up @@ -129,21 +142,25 @@ public void SAVE(List<IPTVman.Model.ParamCanal> lst, string title)
/// <param name="_text_title"></param>
/// <param name="_chek1"></param>
/// <param name="_chek2"></param>
public async void LOAD(List<IPTVman.Model.ParamCanal> lst, string _text_title, bool _chek1, bool _chek2)
public async void LOAD(string path, List<IPTVman.Model.ParamCanal> lst, string _text_title, bool _chek1, bool _chek2)
{
text_title = _text_title;
chek1 = _chek1;
chek2 = _chek2;

string name = "";

OpenFileDialog openFileDialog = new OpenFileDialog();

if (openFileDialog.ShowDialog() == true)
if (path == "")
{
name = openFileDialog.FileName;
OpenFileDialog openFileDialog = new OpenFileDialog();

if (openFileDialog.ShowDialog() == true)
{
name = openFileDialog.FileName;
}
else { loc.openfile = false; return; }
}
else { loc.openfile = false; return; }
else name = path;

await AsyncOPEN(lst, name);
}
Expand All @@ -166,12 +183,13 @@ public async Task<string> AsyncOPEN(List<IPTVman.Model.ParamCanal> lst, string n
{
try
{
Wait.Create("Идет анализ файла", true);
Wait.Create("Идет анализ файла ", true);
mode_work_with_links = true;
bufferstring.Clear();
if (name != "") PARSING_FILE(lst, name);
if (name != "") { Trace.WriteLine("start parsing " +name); PARSING_FILE(lst, name); }
else loc.openfile = false;



Thread.Sleep(300);
Wait.Close();
if (Event_UpdateLIST != null) Event_UpdateLIST(typefilter.normal);
Expand Down Expand Up @@ -231,15 +249,30 @@ void Parsing_link(string s)
}
}

string READLINE(StreamReader sr)
/// <summary>
/// Чтение строки
/// </summary>
/// <param name="sr">указатель</param>
/// <param name="noFINDscr">true - только чтение без анализа</param>
/// <returns></returns>
string READLINE(StreamReader sr, bool noFINDscr)
{
string line = sr.ReadLine();
if (noFINDscr) return line;
if (line!="") Wait.progressbar++;
//Debug.WriteLine(">" + line);

//Trace.WriteLine(">" + line);
line = IPTVman.ViewModel.scripts.FIND_SCRIPT(line);

while (IPTVman.Model.ModeWork.process_adding)
{
Thread.Sleep(100);
}
return line;
}



bool wait_download = false;
bool mode_work_with_links = false;
/// <summary>
Expand Down Expand Up @@ -274,7 +307,7 @@ void PARSING_FILE(List<IPTVman.Model.ParamCanal> lst, string name)
{
while (!sr.EndOfStream)
{
string rez = READLINE(sr);
string rez = READLINE(sr, true);
if (rez != "" && rez != null)
if (new Regex("#EXTINF").Match(rez).Success) { all_str++; null_str = 0; }
else null_str++; if (null_str > 100) goto exit_open;
Expand All @@ -296,7 +329,7 @@ void PARSING_FILE(List<IPTVman.Model.ParamCanal> lst, string name)

while (!sr.EndOfStream)
{
line = READLINE(sr);
line = READLINE(sr, false);

if (linkIsBad(line)) continue;
//MessageBox.Show(line);
Expand Down Expand Up @@ -411,7 +444,7 @@ void PARSING_FILE(List<IPTVman.Model.ParamCanal> lst, string name)
{
try
{
str_http = READLINE(sr);
str_http = READLINE(sr, true);

}
catch { }
Expand Down Expand Up @@ -546,7 +579,7 @@ void PARSING_FILE(List<IPTVman.Model.ParamCanal> lst, string name)
if (ct_dublicat != 0) dialog.Show("Пропущенно дублированных ссылок " + ct_dublicat.ToString());
if (ct_ignore_update != 0) addstr = "\nПропущено дублирование " + ct_ignore_update.ToString();
}
if (!flag_adding_ok) dialog.Show("Каналы не обнаружены");
if (!flag_adding_ok && !ModeWork.flag_add) dialog.Show("Каналы не обнаружены");
if (ct_update != 0) dialog.Show("ОБНОВЛЕНО " + ct_update.ToString() + " каналов" + addstr);

loc.openfile = false;
Expand Down
15 changes: 14 additions & 1 deletion IPTVmanager/UserClass/Scripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ static class scripts
{
public static string FIND_SCRIPT(string line)
{
int ct = 0;
//наличие скрипта
if (new Regex("%").Match(line).Success)
{
string[] split = line.Split(new Char[] { '%' });

foreach (var str in split)
{
ct++;
//Debug.WriteLine("--- "+str);
if (str == null || str == "") continue;
if (new Regex("http://").Match(str).Success) line = str.Trim();
Expand All @@ -42,10 +44,21 @@ public static string FIND_SCRIPT(string line)
IPTVman.Model.ModeWork.OpenWindow_radio = true;
}

if (new Regex("CLOSE").Match(str).Success)
if (new Regex("CLOSEIPTVMANAGER").Match(str).Success)
{
IPTVman.Model.ModeWork.CLOSE_ALL = true;
}

if (new Regex("ADDFILE").Match(str).Success)
{
Debug.WriteLine("find script addfile "+line);
if (split[ct] != null)
{
IPTVman.Model.ModeWork.add = true;
IPTVman.Model.ModeWork.addpath = split[ct];
IPTVman.Model.ModeWork.process_adding = true;
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion IPTVmanager/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private void best1_TextChanged(object sender, System.Windows.Controls.TextChange
private void MYLIST_MouseDoubleClick_EDIT(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (LongtaskPingCANCELING.isENABLE()) return;
if (win1 != null) return;
if (win1 != null) win1.Close();
int si = MYLIST.SelectedIndex;
if (si < 0) { return; }
var p = MYLIST.SelectedItem as ParamCanal;
Expand Down
2 changes: 1 addition & 1 deletion IPTVmanager/View/WindowWAIT.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void Timer1Tick(object source, System.Timers.ElapsedEventArgs e)

txtMessage.Dispatcher.Invoke(new Action(() =>
{
if (!Wait.dynamic_progressbar)
if (!Wait.dynamic_progressbar && proc>0 && proc<100)
{
txtMessage.Text = Wait.message + " " +
String.Format("{0:f1}%", proc);
Expand Down
8 changes: 4 additions & 4 deletions IPTVmanager/ViewModel/MOVE/WindowMOVE.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@

</Button>
<Button x:Name="dec" Content="-" HorizontalAlignment="Right" Margin="0,165,21,0" Grid.Row="1" VerticalAlignment="Top" Width="34" Height="34" RenderTransformOrigin="-0.319,0.627" Foreground="#FF89AC2D" Click="dec_Click"/>
<Button x:Name="button_Copy1" Content="Применить" HorizontalAlignment="Right" Margin="0,12,26,0" Grid.Row="1" VerticalAlignment="Top" Width="70" Height="34" RenderTransformOrigin="-0.319,0.627" Click="button_Click" Foreground="#FF89AC2D">
<Button x:Name="button_Copy1" Content="Применить" HorizontalAlignment="Right" Margin="0,12,26,0" Grid.Row="1" VerticalAlignment="Top" Width="70" Height="34" RenderTransformOrigin="-0.319,0.627" Click="button_Click" Foreground="#FFDCD9EA">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF1333FF" Offset="0.082"/>
<GradientStop Color="#FF2E3C93" Offset="0.082"/>
</LinearGradientBrush>
</Button.Background>
</Button>
<Button x:Name="buttonSEL" Content="Выборка" HorizontalAlignment="Right" Margin="0,100,25,0" Grid.Row="1" VerticalAlignment="Top" Width="70" Height="34" RenderTransformOrigin="-0.319,0.627" Foreground="#FF305A83" Click="buttonSEL_Click">
<Button x:Name="buttonSEL" Content="Выборка" HorizontalAlignment="Right" Margin="0,100,25,0" Grid.Row="1" VerticalAlignment="Top" Width="70" Height="34" RenderTransformOrigin="-0.319,0.627" Foreground="#FF308352" Click="buttonSEL_Click" FontWeight="Bold">
<Button.Background>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF0E236A" Offset="0.082"/>
<GradientStop Color="#FF0E166A" Offset="0.1"/>
</RadialGradientBrush>
</Button.Background>
</Button>
Expand Down
2 changes: 1 addition & 1 deletion IPTVmanager/ViewModel/MOVE/WindowRadioList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF5F6C34" Offset="1"/>
<GradientStop Color="#FF265924" Offset="0.569"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
Expand Down
2 changes: 1 addition & 1 deletion IPTVmanager/ViewModel/MOVE/WindowRadioList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ int num_open_process()
void init_scan_process()
{

myProcesses = Process.GetProcessesByName(NAMEPLAYER);
myProcesses = Process.GetProcessesByName(NAMEPLAYER);

play.path = System.Reflection.Assembly.GetExecutingAssembly().Location + "Player/" + NAMEPLAYERexe;
play.path = play.path.Replace(@"\", @"/");
Expand Down
2 changes: 1 addition & 1 deletion IPTVmanager/ViewModel/MOVE/WindowSelection.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void button_ADD(object sender, RoutedEventArgs e)

_file = new FileWork();
_file.Task_Completed += _file_Task_Completed;
_file.LOAD(ViewModelMain.myLISTselect, title, false, false);
_file.LOAD("",ViewModelMain.myLISTselect, title, false, false);
}

private void _file_Task_Completed()
Expand Down
19 changes: 16 additions & 3 deletions IPTVmanager/ViewModel/ViewModelMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ namespace IPTVman.ViewModel

partial class ViewModelMain : ViewModelBase
{
public static event Action<string> EVENT_ADD;
public static event Action EVENT_CLOSE_ALL;
public static event Action EVENT_OPENWIN_UpdateDB;
public static event Action EVENT_OPENWIN_Radio;
public static event Action<int> Event_UpdateLIST;

Update_Collection _update = new Update_Collection();
Expand Down Expand Up @@ -111,9 +115,7 @@ void CreateTMR(int s)
tmr.Start();
}

public static event Action EVENT_CLOSE_ALL;
public static event Action EVENT_OPENWIN_UpdateDB;
public static event Action EVENT_OPENWIN_Radio;

private void timerTick(object sender, EventArgs e)
{
if (loc.timer_tmr) return;
Expand All @@ -137,6 +139,17 @@ private void timerTick(object sender, EventArgs e)
tmr = null;
}

if (ModeWork.add )
{
ModeWork.skip_message_skiplinks = true;
if (EVENT_ADD != null)
{
ModeWork.add = false;
EVENT_ADD(FileWork.Get_ApplPath() + IPTVman.Model.ModeWork.addpath);
}
}

Trace.WriteLine("tik timer");
loc.timer_tmr = false;

}
Expand Down
20 changes: 19 additions & 1 deletion IPTVmanager/ViewModel/ViewModelMain_Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ void ini_command()

IPTVman.ViewModel.ViewModelMain.EVENT_OPENWIN_UpdateDB += ViewModelMain_EVENT_OPENWIN_UpdateDB;
IPTVman.ViewModel.ViewModelMain.EVENT_OPENWIN_Radio += ViewModelMain_EVENT_OPENWIN_Radio;
IPTVman.ViewModel.ViewModelMain.EVENT_ADD += ViewModelMain_EVENT_ADD;
}

private void ViewModelMain_EVENT_ADD(string obj)
{
key_OPENEVENT(obj);
}

private void ViewModelMain_EVENT_OPENWIN_Radio()
Expand Down Expand Up @@ -597,15 +602,28 @@ void key_OPEN(object parameter)
CollectionisCreate();

FileWork _file = new FileWork();
_file.LOAD(ViewModelMain.myLISTfull, text_title, chek1, chek2);
_file.LOAD("", ViewModelMain.myLISTfull, text_title, chek1, chek2);

text_title = _file.text_title;
_file = null;
loc.openfile = false;
}

void key_OPENEVENT(string path)
{
CollectionisCreate();
Trace.WriteLine("open event");
ModeWork.flag_add = true;

FileWork _file = new FileWork();
_file.LOAD(path, ViewModelMain.myLISTfull, text_title, chek1, chek2);

text_title = _file.text_title;
_file = null;

ModeWork.skip_message_skiplinks = true;
ModeWork.process_adding = false;
}

}//class
}//namespace

0 comments on commit e73a75c

Please sign in to comment.