static void Main(string[] args) { var loggingService = new FileLoggingService(); loggingService.LogFilename = "TestConsole.log"; loggingService.WriteToOutput = true; Console.WriteLine("..."); /* * var tvService = new O2TV(loggingService); * * if (JSONObject.FileExists("O2TV.credentials.json")) * { * //credentials.json: * // { * // "Username": "******", * // "password": "******" * // } * * var credentials = JSONObject.LoadFromFile<Credentials>("O2TV.credentials.json"); * tvService.SetConnection(credentials.Username, credentials.Password); * } */ var tvService = new KUKITV(loggingService); if (JSONObject.FileExists("kuki.json")) { var conn = JSONObject.LoadFromFile <DeviceConnection>("kuki.json"); tvService.SetConnection(conn.deviceId, null); } /* * var tvService = new SledovaniTV(loggingService); * * if (JSONObject.FileExists("credentials.json")) * { * var credentials = JSONObject.LoadFromFile<Credentials>("credentials.json"); * tvService.SetCredentials(credentials.Username, credentials.Password, credentials.ChildLockPIN); * } * */ /* * if (JSONObject.FileExists("connection.json")) * { * var conn = JSONObject.LoadFromFile<DeviceConnection>("connection.json"); * tvService.SetConnection(conn.deviceId, conn.password); * } */ /* * if (JSONObject.FileExists("dvbStreamer.json")) * { * var conn = JSONObject.LoadFromFile<DeviceConnection>("dvbStreamer.json"); * tvService.SetConnection(conn.deviceId, null); * } */ Task.Run( async() => { await tvService.Login(); /* * var qualities = await tvService.GetStreamQualities(); * foreach (var q in qualities) * { * Console.WriteLine(q.Name.PadRight(20) + " " + q.Id.PadLeft(10) + " " + q.Allowed); * } */ //await tvService.Unlock(); //await sledovaniTV.Lock(); var channels = await tvService.GetChanels(); foreach (var ch in channels) { Console.WriteLine(ch.Name); Console.WriteLine(" ID :" + ch.Id); Console.WriteLine(" EPGID :" + ch.EPGId); Console.WriteLine(" Number :" + ch.ChannelNumber); Console.WriteLine(" Locked :" + ch.Locked); Console.WriteLine(" Url :" + ch.Url); Console.WriteLine(" Type :" + ch.Type); Console.WriteLine(" Group :" + ch.Group); Console.WriteLine(" LogoUrl:" + ch.LogoUrl); Console.WriteLine("-----------------------"); } /* * var channelsEPG = await tvService.GetChannelsEPG(); * foreach (var epg in channelsEPG) * { * Console.WriteLine($" {epg.Key}"); * foreach (var epgItem in epg.Value) * { * var time = epgItem.Start.ToString("dd.MM.yyyy HH:mm") + "-" + epgItem.Finish.ToString("HH:mm"); * Console.WriteLine($" {time} : {epgItem.Title} [{epgItem.EPGId}]"); * * // getting EPG detail: * * var description = await tvService.GetEPGItemDescription(epgItem); * * Console.WriteLine($" {description}"); * } * } */ //Console.WriteLine(); //Console.WriteLine("Press any key"); }); Console.ReadKey(); }
public static void Main(string[] args) { var _loggerService = new BasicLoggingService(); _loggerService.MinLevel = LoggingLevelEnum.Debug; var prgSettings = ParseArgs(args); if (!prgSettings.Valid) { return; } var tvService = new SledovaniTV(_loggerService); if (!JSONObject.FileExists(prgSettings.CredentialsFilePath)) { Console.WriteLine($"File {prgSettings.CredentialsFilePath} not found!"); Console.WriteLine(""); Console.WriteLine("Example:"); Console.WriteLine("{"); Console.WriteLine(" \"Username\": \"username\","); Console.WriteLine(" \"Password\": \"password\","); Console.WriteLine(" \"ChildLockPIN\": \"pin\""); Console.WriteLine("}"); return; } Console.WriteLine($"Url: {prgSettings.Url}"); var uri = new Uri(prgSettings.Url); var eventIdParam = HttpUtility.ParseQueryString(uri.Query).Get("eventId"); Console.WriteLine($"EventId: {eventIdParam}"); var credentials = JSONObject.LoadFromFile <Credentials>(prgSettings.CredentialsFilePath); tvService.SetCredentials(credentials.Username, credentials.Password, credentials.ChildLockPIN); if (JSONObject.FileExists(prgSettings.ConnectionFilePath)) { var conn = JSONObject.LoadFromFile <DeviceConnection>(prgSettings.ConnectionFilePath); tvService.SetConnection(conn.deviceId, conn.password); } Task.Run( async() => { Console.WriteLine(); Console.WriteLine($"Logging SledovaniTV ....."); await tvService.Login(); if (!JSONObject.FileExists(prgSettings.ConnectionFilePath)) { tvService.Connection.SaveToFile(prgSettings.ConnectionFilePath); } Console.WriteLine($"SledovaniTV status: {tvService.Status}"); Console.WriteLine($"SledovaniTV PHPSESSID: {tvService.PHPSESSID}"); var silentFlag = prgSettings.Silent ? "c" : ""; var streamUrl = $"http://sledovanitv.cz/vlc/api-timeshift/event.m3u8?PHPSESSID={tvService.PHPSESSID}&eventId={HttpUtility.UrlEncode(eventIdParam)}"; var vlcParams = $"\"{streamUrl}\" --sout='#duplicate{{dst=display,dst=standard{{access=file,mux=mkv,dst={prgSettings.PathToMKV}}}}}'"; if (prgSettings.Silent) { vlcParams = $"\"{streamUrl}\" --sout='#standard{{access=file,mux=mkv,dst={prgSettings.PathToMKV}}}'"; } Console.WriteLine($"vlcParams: {vlcParams}"); Process.Start($"{silentFlag}vlc", vlcParams); }).Wait(); }