private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //TODO: Es gibt noch kein Item für die Anwendung
            //Icon = Properties.Resources.Werkbuch464x64.ToImageSource();
            var settings = PageEinstellungen.GetInstance() ?? new PageEinstellungen();

            //Api instanziieren
            dvbApi = new DVBViewerServerApi
            {
                Hostname        = settings.Hostname,
                Port            = settings.Port,
                User            = settings.Username,
                Password        = settings.Password,
                TrustedDevice   = settings.TrustedDevice,
                BypassLocalhost = settings.BypassLocalhost
            };

            //Wenn etwas bei der Instanziierung schief geht, dann gehe direkt zur Einstellungsseite
            try
            {
                var version = dvbApi.ServerVersion;
                Title = $"DMSApiWrapperDemo {Assembly.GetExecutingAssembly().GetName().Version}";
                Title = $"{Title} - {Properties.Resources.ConnectedWith} {version.Version}";
                error = false;
            }
            catch (Exception)
            {
                error = true;
                frameContent.Navigate(settings);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gibt den Serverstatus zurück. Returns the server status.
        /// </summary>
        /// <returns></returns>
        public async static Task <Serverstatus> GetServerstatusAsync()
        {
            var api = DVBViewerServerApi.GetCurrentInstance();

            if (api != null)
            {
                return(CreateServerstatus(await api.GetApiDataAsync().ConfigureAwait(false)));
            }
            return(null);
        }
        /// <summary>
        /// Gibt die komplette URL zum Logo des Kanals zurück. Gives back the complete URL to the channel logo.
        /// </summary>
        /// <returns></returns>
        public async Task <string> GetChannelLogoAsync()
        {
            var api = DVBViewerServerApi.GetCurrentInstance();

            if (api != null && ChannelLogo != null)
            {
                return(await Task.Run(() => $"http://{api.Hostname}:8889/{ChannelLogo.Replace("Logo", "logo")}").ConfigureAwait(false));
            }

            return(null);
        }
        /// <summary>
        /// Gibt eine Liste aller Sender zurück.
        /// Returns a list of all channels.
        /// </summary>
        /// <returns></returns>
        public static async Task <List <RecordingChannel> > GetChannelsAsync()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                var recs = await RecordingList.GetRecordingsAsync().ConfigureAwait(false);

                return((from f in recs.Items where f.Channel?.Name != null orderby f.Channel.Name select f.Channel).Distinct().ToList());
            }
            return(null);
        }
        /// <summary>
        /// Gibt die Serverversion zurück. Returns the server version.
        /// </summary>
        /// <returns></returns>
        public static async Task <ServerVersion> GetServerVersionAsync()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                var xmldata = await dvbApi.GetApiDataAsync("version").ConfigureAwait(false);

                if (xmldata != null)
                {
                    return(CreateServerVersion(xmldata));
                }
            }
            return(null);
        }
        /// <summary>
        /// Startet den Task auf dem Server.
        /// Starts the task on the server
        /// </summary>
        /// <returns></returns>
        public Task <HttpStatusCode> RunTaskAsync()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                return(dvbApi.SendApiDataAsync("tasks", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("task", Action)
                }));
            }
            else
            {
                return(Task.FromResult <HttpStatusCode>(0));
            }
        }
        /// <summary>
        /// Löscht das EPG.
        /// Clears the EPG.
        /// </summary>
        /// <param name="epgClear">If is not specified the default is: all EPG data will be deleted (default value of the options is 7)</param>
        /// <returns></returns>
        public static Task <HttpStatusCode> DeleteEpgAsync(Enums.EpgClearSources epgClear = Enums.EpgClearSources.DVB | Enums.EpgClearSources.MHW | Enums.EpgClearSources.External)
        {
            var api = DVBViewerServerApi.GetCurrentInstance();

            if (api != null)
            {
                return(api.SendApiDataAsync("egpclear", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("source", $"{(int)epgClear}")
                }));
            }
            else
            {
                return(Task.FromResult <HttpStatusCode>(0));
            }
        }
        /// <summary>
        /// Generates a List of T. So T have to be an object from the <see cref="Model"/> namespace!
        /// </summary>
        /// <typeparam name="T">The list which should be generated.</typeparam>
        /// <param name="page">The page which should be called.</param>
        /// <param name="uriParameters">The UriParameters for the page</param>
        /// <param name="others">Others is an array of classes to be additionally generated by the deserializer.</param>
        /// <returns></returns>
        internal static async Task <T> GetListAsync <T>(string page, List <UriParameter> uriParameters, Type[] others = null)
        {
            //get the current instance of the main Api Class
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                //Get the XML-Data from the server
                var xmldata = await dvbApi.GetApiDataAsync(page, uriParameters).ConfigureAwait(false);

                if (xmldata != null)
                {
                    //Deserialize the xml-Data to the objects
                    return(Deserializer.Deserialize <T>(xmldata, others));
                }
            }
            return(default);
        /// <summary>
        /// Sendet einen Befehl an den Clienten und gibt einen Statuscode über die Antwort zurück.
        /// Sends a command to the client and returns a status code about the response.
        /// </summary>
        /// <param name="dVBViewerCommand"></param>
        /// <returns></returns>
        public Task <HttpStatusCode> SendXCommandAsync(Enums.DVBViewerXCommand dVBViewerCommand)
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                return(dvbApi.SendApiDataAsync("dvbcommand", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("target", Name),
                    new Helper.UriParameter("cmd", $"-x{(int)dVBViewerCommand}")
                }));
            }
            else
            {
                return(Task.FromResult <HttpStatusCode>(0));
            }
        }
Beispiel #10
0
        /// <summary>
        /// Löscht diese Aufnahme, gibt den Code 423 zurück, wenn eine Löschung nicht funktioniert hat.
        /// Deletes this recording, returns the code 423, if a deletion did not work.
        /// </summary>
        /// <returns></returns>
        public Task <HttpStatusCode> DeleteAsync()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                return(dvbApi.SendApiDataAsync("recdelete", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("recid", ID.ToString()),
                    new Helper.UriParameter("delfile", 1.ToString())
                }));
            }
            else
            {
                return(Task.FromResult <HttpStatusCode>(0));
            }
        }
        /// <summary>
        /// Spielt das Video auf dem Clienten (DVBViewer) ab, sofern dieser connected ist.
        /// Plays the video on the client (DVBViewer), if it is connected.
        /// </summary>
        /// <param name="videoFileItem"></param>
        /// <returns></returns>
        public Task <HttpStatusCode> PlayVideoAsync(VideoFileItem videoFileItem)
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                return(dvbApi.SendApiDataAsync("dvbcommand", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("target", Name),
                    new Helper.UriParameter("cmd", videoFileItem.Path + videoFileItem.FileName)
                }));
            }
            else
            {
                return(Task.FromResult <HttpStatusCode>(0));
            }
        }
        /// <summary>
        /// Spiel den Sender auf dem DVBViewer ab. Play the subchannel on the DVBViewer.
        /// </summary>
        /// <param name="channelSubItem"></param>
        /// <returns></returns>
        public Task <HttpStatusCode> PlayChannelAsync(ChannelSubItem channelSubItem)
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                return(dvbApi.SendApiDataAsync("dvbcommand", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("target", Name),
                    new Helper.UriParameter("cmd", $"-c:{channelSubItem.ChannelID}")
                }));
            }
            else
            {
                return(Task.FromResult <HttpStatusCode>(0));
            }
        }
        /// <summary>
        /// Erzeugt aus dem Kanal eine M3U Datei. Die Datei befindet sich normalerweise im Tempverzeichnis.
        /// Generates an M3U file from this channel. The file is usually located in the Temp directory
        /// </summary>
        /// <returns>Ein Pfad zur m3u Datei. A path to the m3u file</returns>
        public string CreateM3UFile()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();
            //Create a playlist
            var tPath     = System.IO.Path.GetTempPath();
            var fName     = $"{ChannelID}.m3u";
            var cPathName = tPath + fName;

            using (var fStream = new System.IO.FileStream(cPathName, System.IO.FileMode.Create))
            {
                using (var sw = new System.IO.StreamWriter(fStream))
                {
                    sw.WriteLine(GetM3uPrefString());
                    sw.WriteLine(GetUPnPUriString());
                }
            }
            return(cPathName);
        }
        /// <summary>
        /// <para>Eine Liste mit Aufnahmen welche irgendwann aufgenommen wurden. Diese müssen nicht mehr als Datei existieren. Es existieren auch keine Verweise auf Dateinamen.
        /// Dies wird verwendet um bereits aufgenommene Aufnahmen zu erkennen.</para>
        /// <para>
        /// A list of recordings that were taken sometime. These no longer need to exist as a file. There are no references to filenames.
        /// This is used to recognize already recorded pictures.
        /// </para>
        /// </summary>
        public static async Task <RecordedList> GetRecordedListAsync()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                var xmldata = await dvbApi.GetApiDataAsync("sql", new List <Helper.UriParameter>
                {
                    Helper.UriParam.Rec1,
                    Helper.UriParam.Query("Select * from recordedlist")
                }).ConfigureAwait(false);

                if (xmldata != null)
                {
                    return(CreateRecordedList(xmldata));
                }
            }
            return(null);
        }
Beispiel #15
0
        /// <summary>
        /// Führt eine Aktualisierung der Aufnahme im Media Server durch. Geändert wird:
        /// Performs an update of the recording in the Media Server. Will be changed:
        /// Title, Info, Series, Channel und Description
        /// </summary>
        /// <returns></returns>
        public async Task <HttpStatusCode> UpdateAsync()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            if (dvbApi != null)
            {
                return(await dvbApi.SendPostDataAsync("rec_edit", new List <Helper.UriParameter>
                {
                    new Helper.UriParameter("recid", ID.ToString()),
                    new Helper.UriParameter("title", Title ?? ""),
                    new Helper.UriParameter("event", Info ?? ""),
                    new Helper.UriParameter("Series", Series?.Name),
                    new Helper.UriParameter("Channel", Channel?.Name),
                    new Helper.UriParameter("details", Description ?? ""),
                    new Helper.UriParameter("chkinfofile", "1"),
                    new Helper.UriParameter("chkfileinfo", "1"),
                    new Helper.UriParameter("btnsave", "1")
                }).ConfigureAwait(false));
            }
            return(0);
        }
Beispiel #16
0
        /// <summary>
        /// Erzeugt aus der Liste der Videos eine M3U Datei. Die Datei befindet sich normalerweise im Tempverzeichnis. Wenn BypassLocalhost true ist, wird der direkte Pfad zur Aufnahme zurückgegeben.
        /// Generates an M3U file from the list of videos. The file is usually located in the Temp directory. If BypassLocalhost is true, the direct path to the mediafile will be returned.
        /// </summary>
        /// <returns>Ein Pfad zur m3u Datei</returns>
        public string CreateM3UFile()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            //Bypassing the playlist creation, if BypassLocalhost is set to true.
            if (dvbApi.BypassLocalhost)
            {
                return(File);
            }
            //Create a Playlist
            var tPath     = System.IO.Path.GetTempPath();
            var fName     = $"{ID}.m3u";
            var cPathName = tPath + fName;

            using (var fStream = new System.IO.FileStream(cPathName, System.IO.FileMode.Create))
            {
                using (var sw = new System.IO.StreamWriter(fStream))
                {
                    sw.WriteLine(GetM3uPrefString());
                    sw.WriteLine(GetUPnPUriString());
                }
            }
            return(cPathName);
        }
        /// <summary>
        /// Gibt eine URL zurück, welche das Video auf einen UPnP Gerät abspielen lässt.
        /// Returns a URL that plays the video on a UPnP device.
        /// </summary>
        /// <returns></returns>
        public string GetUPnPUriString()
        {
            var dvbApi = DVBViewerServerApi.GetCurrentInstance();

            return($"http://{dvbApi.Hostname}:8090/upnp/video/{ObjectID.ToString("D5")}{FileExtension}?d={Duration}");
        }
        static void Main(string[] args)
        {
            var dvbServ = new DVBViewerServerApi
            {
                IpAddress = "192.168.2.101",
                User      = "******",
                Port      = 8089
            };

            //Define new SecureString
            var spw = new SecureString();

            var pw = "integrale";

            foreach (char item in pw)
            {
                spw.AppendChar(item);
            }

            //Set the password
            dvbServ.Password = spw;
            pw  = null;
            spw = null;

            try
            {
                var clients = DVBViewerClients.GetDVBViewerClientsAsync().Result;
                var client  = clients.Items[0];
                var test    = ChannelList.GetChannelListAsync().Result;

                //var sw = new Stopwatch();
                //sw.Start();
                //var epgList = EpgList.GetEpgList();
                //sw.Stop();
                //Console.WriteLine($"EPGList with {epgList.Items.Count} entrys. Needed to load {sw.Elapsed.TotalSeconds} seconds.");

                //Gets the Channel 3Sat HD from the server. (Satellite)
                var sat3 = ChannelList.GetChannelList($"{2359890891631983072}").TopGroups[0].Groups[0].Items[0];
                Console.WriteLine($"EPG Channel ID: {sat3.EpgChannelID}");
                Console.WriteLine($"Channelname: {sat3.Name}");

                //Current EPG Title
                var sat3EpgList = sat3.GetEpgListNow();
                //The sat3EpgList.Items.Count is only 1
                Console.WriteLine($"Current Title: {sat3EpgList.Items[0].Title}");

                //alle Timer holen
                var lTimer = TimerList.GetTimerListAsync().Result;
                //ersten Timer auswählen
                var timer0 = lTimer.Items[0];
                //Epg anzeigen
                var epgLTimer = timer0.EpgListAsync.Result;
                Console.WriteLine($"Timer 0: Channel: {timer0.ChannelItem.Name}, Timername: {timer0.Description} has the EPG Description: {epgLTimer.Items[0].Description}");
                Console.WriteLine($"Timer 0: The channel: {timer0.ChannelList.TopGroups[0].Groups[0].Items[0].Name}, currently has the EPG: {timer0.ChannelList.TopGroups[0].Groups[0].Items[0].EpgListNow.Items[0].Title} - {timer0.ChannelList.TopGroups[0].Groups[0].Items[0].EpgListNow.Items[0].Description}");


                var status = Serverstatus.GetServerstatus();

                Console.WriteLine($"Die Rechte sind: {status.Rights}");
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    Console.WriteLine(ex.Message);
                }
                else
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
            }

            Console.ReadKey();
        }