Exemplo n.º 1
0
        public static List <string> getFieldNameListFromList <T>(string FieldNameToGet, List <T> elements) where T : DBTable
        {
            MPTVSeriesLog.Write("Elements found: " + elements.Count.ToString());
            List <string> results = new List <string>();

            foreach (T elem in elements)
            {
                try
                {
                    results.Add((string)elem[FieldNameToGet]);
                }
                catch (Exception)
                {
                    MPTVSeriesLog.Write("Wrong call of getPropertyListFromList<T,P>: Type " + elem.GetType().Name);
                }
            }
            return(results);
        }
Exemplo n.º 2
0
 public virtual DBValue this[String fieldName]
 {
     get
     {
         DBField result;
         if (!m_fields.TryGetValue(fieldName, out result))
         {
             return(string.Empty);
         }
         return(result.Value);
     }
     set
     {
         try
         {
             DBField result;
             if (m_fields.TryGetValue(fieldName, out result))
             {
                 if (result.Value != value)
                 {
                     if (result.Type == DBField.cTypeInt)
                     {
                         result.Value = (long)value;
                     }
                     else
                     {
                         result.Value = value;
                     }
                     result.WasChanged = true;
                     m_CommitNeeded    = true;
                 }
             }
             else
             {
                 AddColumn(fieldName, new DBField(DBField.cTypeString));
                 this[fieldName] = value;
             }
         }
         catch (SystemException)
         {
             MPTVSeriesLog.Write("Cast exception when trying to assign " + value + " to field " + fieldName + " in table " + m_tableName);
         }
     }
 }
Exemplo n.º 3
0
        public int MovePlayListItemDown(int iItem)
        {
            int selectedItemIndex = -1;

            if (iItem < 0 || iItem >= _listPlayListItems.Count)
            {
                return(-1);
            }

            int iNextItem = iItem + 1;

            if (iNextItem >= _listPlayListItems.Count)
            {
                iNextItem = 0;
            }

            PlayListItem playListItem1 = _listPlayListItems[iItem];
            PlayListItem playListItem2 = _listPlayListItems[iNextItem];

            if (playListItem1 == null || playListItem2 == null)
            {
                return(-1);
            }

            try
            {
                MPTVSeriesLog.Write(string.Format("Moving playlist item {0} down. Old index:{1}, new index{2}", playListItem1.EpisodeName, iItem, iNextItem));
                System.Threading.Monitor.Enter(this);
                _listPlayListItems[iItem]     = playListItem2;
                _listPlayListItems[iNextItem] = playListItem1;
                selectedItemIndex             = iNextItem;
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write(string.Format("PlayList.MovePlayListItemDown caused an exception: {0}", ex.Message));
                selectedItemIndex = -1;
            }
            finally
            {
                System.Threading.Monitor.Exit(this);
            }

            return(selectedItemIndex);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a List of Fanarts in your Thumbs folder
        /// </summary>
        void getFanart()
        {
            string fanartFolder = Settings.GetPath(Settings.Path.fanart);

            // Check if Fanart folder exists in MediaPortal's Thumbs directory
            if (System.IO.Directory.Exists(fanartFolder))
            {
                MPTVSeriesLog.Write("Checking for Fanart on series: ", Helper.getCorrespondingSeries(_seriesID).ToString(), MPTVSeriesLog.LogLevel.Debug);
                try
                {
                    // Create a Filename filter for Season / Series Fanart
                    string seasonFilter = string.Format(seasonFanArtFilenameFormat, _seriesID, _seasonIndex);
                    string seriesFilter = string.Format(seriesFanArtFilenameFormat, _seriesID);

                    string filter = _seasonMode ? seasonFilter : seriesFilter;

                    _fanArts = new List <string>();
                    // Store list of all fanart files found in all sub-directories of fanart thumbs folder
                    _fanArts.AddRange(System.IO.Directory.GetFiles(fanartFolder, filter, System.IO.SearchOption.AllDirectories));

                    // If no Season Fanart was found, see if any Series fanart exists
                    if (_fanArts.Count == 0 && _seasonMode)
                    {
                        MPTVSeriesLog.Write("No Season Fanart found on disk, searching for series fanart", MPTVSeriesLog.LogLevel.Debug);
                        _fanArts.AddRange(System.IO.Directory.GetFiles(fanartFolder, seriesFilter, System.IO.SearchOption.AllDirectories));
                    }

                    // Remove any files that we dont want e.g. thumbnails in the _cache folder
                    // and Season fanart if we are not in Season Mode
                    if (!_seasonMode)
                    {
                        removeSeasonFromSeries();
                    }
                    removeFromFanart("_cache");

                    MPTVSeriesLog.Write("Number of fanart found on disk: ", _fanArts.Count.ToString(), MPTVSeriesLog.LogLevel.Debug);
                }
                catch (Exception ex)
                {
                    MPTVSeriesLog.Write("An error occured looking for fanart: " + ex.Message);
                }
            }
        }
Exemplo n.º 5
0
 private void radOptionSelected(int selectedOption)
 {
     if (selectedOption > m_descriptor.m_List.Count)
     {
         MPTVSeriesLog.Write("Selected an unavailable Option....");
         return;
     }
     Feedback.CItem item = m_descriptor.m_List[selectedOption];
     if (item != null)
     {
         if (item.m_sDescription != "")
         {
             this.Text = origTitle + " (" + item.m_sName + ")";
             this.textbox_Description.Text = item.m_sDescription;
         }
         SelectedItemRadOption = item;
         button_OK.Text        = m_descriptor.m_sbtnOKLabel;
     }
 }
Exemplo n.º 6
0
        private void onStopExternal(Process proc, bool waitForExit)
        {
            if (!listenToExternalPlayerEvents)
            {
                return;
            }

            MPTVSeriesLog.Write("Playback Stopped in External Player:" + m_currentEpisode.ToString());

            // Exit fullscreen Video so we can see main facade again
            if (GUIGraphicsContext.IsFullScreenVideo)
            {
                GUIGraphicsContext.IsFullScreenVideo = false;
            }
            // Mark Episode as watched regardless and prompt for rating
            bool markAsWatched = (DBOption.GetOptions(DBOption.cWatchedAfter) > 0 && m_currentEpisode[DBOnlineEpisode.cWatched] == 0);

            PlaybackOperationEnded(markAsWatched);
        }
Exemplo n.º 7
0
        string RunReplacements(Dictionary <Regex, string> replacements, string runAgainst)
        {
            string _beforeReplacement = runAgainst;

            foreach (var replacement in replacements)
            {
                if (replacement.Key.IsMatch(runAgainst) &&
                    tags.Contains(replacement.Key.ToString()))
                {
                    m_Tags.Add(replacement.Key.ToString());
                }

                runAgainst = replacement.Value.Equals("<RomanToArabic>", StringComparison.OrdinalIgnoreCase) // special case romans
                         ? replacement.Key.Replace(runAgainst, m => " " + Parse1To19RomanNumberOrKeep(m.Value) + " ")
                         : replacement.Key.Replace(runAgainst, replacement.Value);
            }
            MPTVSeriesLog.Write("Replacement: " + _beforeReplacement + " -> " + runAgainst, MPTVSeriesLog.LogLevel.Debug);
            return(runAgainst);
        }
Exemplo n.º 8
0
        private void onStopExternal(Process proc, bool waitForExit)
        {
            if (!listenToExternalPlayerEvents)
            {
                return;
            }

            MPTVSeriesLog.Write("Playback Stopped in External Player");
            SetAsWatched();
            PlayNext();
            if (!g_Player.Playing)
            {
                g_Player.Release();

                // Clear focus when playback ended
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null);
                GUIGraphicsContext.SendMessage(msg);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Read Logo Rules and Import into Database
        /// </summary>
        /// <param name="doc"></param>
        private static void GetLogoRules(XmlDocument doc)
        {
            XmlNode node = null;

            node = doc.DocumentElement.SelectSingleNode("/settings/logos");
            if (node != null && node.Attributes.GetNamedItem("import").Value.ToLower() == "true")
            {
                MPTVSeriesLog.Write("Loading Skin Logo Rules", MPTVSeriesLog.LogLevel.Normal);

                DBOption.SetOptions("logoConfig", "");
                List <string> logos = new List <string>();
                foreach (string rule in node.InnerText.Split('\n'))
                {
                    logos.Add(rule.Trim());
                }
                localLogos.saveToDB(logos);
                ImportLogos = true;
            }
        }
Exemplo n.º 10
0
        static string buildLogoImage(List <string> logosForBuilding, bool firstOnly, int imgWidth, int imgHeight)
        {
            try
            {
                if (logosForBuilding.Count == 1 || (firstOnly && logosForBuilding.Count > 0))
                {
                    return(logosForBuilding[0]);
                }
                else if (logosForBuilding.Count > 1)
                {
                    tmpFile = string.Empty;
                    foreach (string logo in logosForBuilding)
                    {
                        tmpFile += System.IO.Path.GetFileNameWithoutExtension(logo);
                    }
                    tmpFile = Helper.PathCombine(pathfortmpfile, "TVSeriesDynLogo" + tmpFile + ".png");

                    Bitmap   b   = new Bitmap(imgWidth, imgHeight);
                    Image    img = b;
                    Graphics g   = Graphics.FromImage(img);
                    appendLogos(logosForBuilding, ref g, imgHeight, imgWidth);
                    if (Settings.isConfig)
                    {
                        b.Save(tmpFile);
                        return(tmpFile);
                    }
                    else
                    {
                        return(ImageAllocator.GetOtherImage(b, tmpFile, new Size(), true)); // don't resize in allocator
                    }
                }
                else
                {
                    return(string.Empty);
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("The Logo Building Engine generated an error: " + ex.Message);
                return(string.Empty);
            }
        }
Exemplo n.º 11
0
        private void OnSavePlayList()
        {
            currentSelectedItem = m_Facade.SelectedListItemIndex;
            string playlistFileName = string.Empty;

            if (GetKeyboard(ref playlistFileName))
            {
                string playListPath = string.Empty;
                playListPath = DBOption.GetOptions(DBOption.cPlaylistPath);
                playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath);

                // check if Playlist folder exists, create it if not
                if (!Directory.Exists(playListPath))
                {
                    try {
                        Directory.CreateDirectory(playListPath);
                    }
                    catch (Exception e) {
                        MPTVSeriesLog.Write("Error: Unable to create Playlist path: " + e.Message);
                        return;
                    }
                }

                string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName);

                fullPlayListPath += ".tvsplaylist";
                if (playListPath.Length != 0)
                {
                    fullPlayListPath = playListPath + @"\" + fullPlayListPath;
                }
                PlayList playlist = new PlayList();
                for (int i = 0; i < m_Facade.Count; ++i)
                {
                    GUIListItem  listItem     = m_Facade[i];
                    PlayListItem playListItem = new PlayListItem();
                    playListItem.Episode = listItem.TVTag as DBEpisode;
                    playlist.Add(playListItem);
                }
                PlayListIO saver = new PlayListIO();
                saver.Save(playlist, fullPlayListPath);
            }
        }
Exemplo n.º 12
0
 public static void SaveXmlCache(string filename, XmlNode node)
 {
     // create cached document
     try
     {
         MPTVSeriesLog.Write("Saving xml to file cache: " + filename, MPTVSeriesLog.LogLevel.Debug);
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(node.OuterXml);
         if (!Directory.Exists(Path.GetDirectoryName(filename)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(filename));
         }
         doc.Save(filename);
     }
     catch (Exception e)
     {
         MPTVSeriesLog.Write("Failed to save xml to cache: {0}", filename);
         MPTVSeriesLog.Write("Exception: {0}", e.Message);
     }
 }
Exemplo n.º 13
0
        public void HideSeason(bool hide)
        {
            MPTVSeriesLog.Write(string.Format("{0} series {1}, season {2} from view", (hide ? "Hiding" : "UnHiding"), Helper.getCorrespondingSeries(this[DBSeason.cSeriesID]), this[DBSeason.cIndex]));

            // respect 'Show Local Files Only' setting
            List <DBEpisode> episodes = DBEpisode.Get(int.Parse(this[DBSeason.cSeriesID]), int.Parse((this[DBSeason.cIndex])));

            if (episodes != null)
            {
                foreach (DBEpisode episode in episodes)
                {
                    // Hide Episodes
                    episode.HideEpisode(hide);
                }
            }

            // Hide Season
            this[DBSeason.cHidden] = hide;
            this.Commit();
        }
Exemplo n.º 14
0
        public bool Insert(PlayListItem item, PlayListItem afterThisItem)
        {
            bool success = false;

            if (item == null)
            {
                return(success);
            }

            for (int i = 0; i < _listPlayListItems.Count; ++i)
            {
                if (afterThisItem.FileName == _listPlayListItems[i].FileName)
                {
                    MPTVSeriesLog.Write(string.Format("Playlist: Insert {0} after {1}", item.FileName, afterThisItem.FileName));
                    _listPlayListItems.Insert(i + 1, item);
                    success = true;
                }
            }
            return(success);
        }
Exemplo n.º 15
0
        public GetFanart(int SeriesID)
        {
            XmlNode node = OnlineAPI.getBannerList(SeriesID);

            if (node == null)
            {
                return;
            }

            foreach (XmlNode fanartNode in node.SelectNodes("/Banners/Banner[BannerType='fanart']"))
            {
                DBFanart dbf = new DBFanart();
                foreach (XmlNode propertyNode in fanartNode.ChildNodes)
                {
                    try
                    {
                        dbf[propertyNode.Name] = propertyNode.InnerText;
                    }
                    catch (Exception ex)
                    {
                        MPTVSeriesLog.Write("Error adding Fanart Property to DBEntry: " + propertyNode.Name + " - " + ex.Message);
                    }
                }

                // Sync local files with database
                string localPath = dbf[DBFanart.cBannerPath];
                localPath = localPath.Replace("/", @"\");
                string fanart = Helper.PathCombine(Settings.GetPath(Settings.Path.fanart), localPath);
                if (File.Exists(fanart))
                {
                    dbf[DBFanart.cLocalPath] = localPath;
                }
                else
                {
                    dbf[DBFanart.cLocalPath] = string.Empty;
                }

                dbf[DBFanart.cSeriesID] = SeriesID;
                _fanart.Add(dbf);
            }
        }
Exemplo n.º 16
0
        void workerWatcher_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Lowest;

            // delay the start of file monitoring for a small period
            // this doesnt really need a config setting but can be manually overridden in DB option
            // purpose of the delay is to allow network devices to get ready after fresh boot from windows
            // and resume from standby...benifits UNC shares as Mapped drives are picked up from Device Manager events.
            // also DoFileScan can be expensive, so we dont want to do this on startup while other plugins/background tasks
            // are running as well.
            Thread.Sleep((int)DBOption.GetOptions(DBOption.cDelayImportPathMonitoringValue) * 1000);

            MPTVSeriesLog.Write("File Watcher: Starting File System Watcher Background Task", MPTVSeriesLog.LogLevel.Normal);
            setUpWatches();

            // do the initial scan
            m_PreviousScan          = Filelister.GetFiles(m_ScannedFolders);
            m_PreviousScanRemovable = Filelister.GetFiles(GetDeviceManagerWatchedFolders());

            DateTime timeLastScan = DateTime.Now;

            // then start the watcher loop
            while (!worker.CancellationPending)
            {
                TimeSpan tsUpdate = DateTime.Now - timeLastScan;
                if ((int)tsUpdate.TotalMinutes >= m_nScanLapse)
                {
                    timeLastScan = DateTime.Now;
                    DoFileScan();
                }

                signalModifiedFiles();

                if (refreshWatchers)
                {
                    setUpWatches();
                }

                Thread.Sleep(1000);
            }
        }
Exemplo n.º 17
0
        void setUpWatches()
        {
            if (m_watchersList.Count > 0)
            {
                MPTVSeriesLog.Write("File Watcher: Cleaning up File System Watchers", MPTVSeriesLog.LogLevel.Normal);

                // do some cleanup first, remove the existing watchers
                foreach (FileSystemWatcher watcher in m_watchersList)
                {
                    watcher.EnableRaisingEvents = false;
                    watcher.Changed            -= new FileSystemEventHandler(watcher_Changed);
                    watcher.Created            -= new FileSystemEventHandler(watcher_Changed);
                    watcher.Deleted            -= new FileSystemEventHandler(watcher_Changed);
                    watcher.Renamed            -= new RenamedEventHandler(watcher_Renamed);
                    watcher.Error -= new ErrorEventHandler(watcher_Error);
                }
                m_watchersList.Clear();
            }

            // go through all enabled import folders, and add a watchfolder on it
            foreach (String sWatchedFolder in m_WatchedFolders)
            {
                if (Directory.Exists(sWatchedFolder))
                {
                    FileSystemWatcher watcher = new FileSystemWatcher();
                    // ZFLH watch for all types of file notification, filter in the event notification
                    // from MSDN, filter doesn't change the amount of stuff looked at internally
                    watcher.Path = sWatchedFolder;
                    watcher.IncludeSubdirectories = true;
                    watcher.NotifyFilter          = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Size;
                    watcher.Changed            += new FileSystemEventHandler(watcher_Changed);
                    watcher.Created            += new FileSystemEventHandler(watcher_Changed);
                    watcher.Deleted            += new FileSystemEventHandler(watcher_Changed);
                    watcher.Renamed            += new RenamedEventHandler(watcher_Renamed);
                    watcher.Error              += new ErrorEventHandler(watcher_Error);
                    watcher.EnableRaisingEvents = true;
                    m_watchersList.Add(watcher);
                }
            }
            refreshWatchers = false;
        }
Exemplo n.º 18
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;
            List <String> listFolders = new List <string>();

            DBImportPath[] importPathes = DBImportPath.GetAll();
            if (importPathes != null)
            {
                foreach (DBImportPath importPath in importPathes)
                {
                    if (importPath[DBImportPath.cEnabled] != 0)
                    {
                        listFolders.Add(importPath[DBImportPath.cPath]);
                    }
                }
            }
            List <PathPair> files = Filelister.GetFiles(listFolders);

            MPTVSeriesLog.Write("Found " + files.Count.ToString() + " supported video files in your import paths");
            e.Result = Parse(files);
        }
Exemplo n.º 19
0
        public static SQLiteResultSet Execute(String query)
        {
            if (m_db == null)
            {
                InitDB();
            }

            SQLite.NET.SQLiteResultSet result;
            try
            {
                MPTVSeriesLog.Write(string.Format("Executing SQL query. Query = '{0}'", query), MPTVSeriesLog.LogLevel.DebugSQL);
                result = m_db.Execute(query);
                MPTVSeriesLog.Write(string.Format("Successfully executed SQL query. Row Count = '{0}'", result.Rows.Count), MPTVSeriesLog.LogLevel.DebugSQL);
                return(result);
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("SQL Execution Failed. Reason = '{0}', Query = '{1}'", ex.Message, query);
                return(new SQLiteResultSet());
            }
        }
Exemplo n.º 20
0
        public static void RemoveWatchDrive(string path)
        {
            string driveLetter = GetDriveLetter(path);

            if (driveLetter == null)
            {
                return;
            }

            lock (syncRoot) {
                if (watchedDrives != null && watchedDrives.Contains(driveLetter))
                {
                    watchedDrives.Remove(driveLetter);
                    MPTVSeriesLog.Write("Removed " + driveLetter + " from Disk Watcher", MPTVSeriesLog.LogLevel.Normal);
                    if (watchedDrives.Count == 0)
                    {
                        StopDiskWatcher();
                    }
                }
            }
        }
Exemplo n.º 21
0
        public GetLanguages()
        {
            XmlNode rootNode = Online_Parsing_Classes.OnlineAPI.GetLanguages();

            if (rootNode != null)
            {
                Language lang = null;
                foreach (XmlNode itemNode in rootNode.ChildNodes)
                {
                    lang = new Language();
                    foreach (XmlNode node in itemNode)
                    {
                        if (node.Name == "id")
                        {
                            int.TryParse(node.InnerText, out lang.Id);
                        }
                        if (node.Name == "name")
                        {
                            lang.Name = node.InnerText;
                        }
                        if (node.Name == "abbreviation")
                        {
                            lang.Abbreviation = node.InnerText;
                            try
                            {
                                lang.EnglishName = new System.Globalization.CultureInfo(lang.Abbreviation).EnglishName;
                            }
                            catch
                            {
                                MPTVSeriesLog.Write($"Unable to get English name for language code '{lang.Abbreviation}'", MPTVSeriesLog.LogLevel.Debug);
                            }
                        }
                    }
                    if (lang.Id != default(int) && lang.EnglishName.Length > 0 && !lang.EnglishName.StartsWith("Unknown"))
                    {
                        languages.Add(lang);
                    }
                }
            }
        }
Exemplo n.º 22
0
        public static void CreateDBIndices(string sCommand, string sTable, bool bSetFlag)
        {
            try
            {
                switch (sTable)
                {
                case "online_episodes":
                    if (m_bIndexOnlineEpisodes)
                    {
                        return;
                    }
                    m_bIndexOnlineEpisodes = bSetFlag;
                    break;

                case "local_episodes":
                    if (m_bIndexLocalEpisodes)
                    {
                        return;
                    }
                    m_bIndexLocalEpisodes = bSetFlag;
                    break;

                case "local_series":
                    if (m_bIndexLocalSeries)
                    {
                        return;
                    }
                    m_bIndexLocalSeries = bSetFlag;
                    break;

                default:
                    return;
                }
                m_db.Execute(sCommand);
            }
            catch (Exception e)
            {
                MPTVSeriesLog.Write("Warning, failed to create Index: " + e.Message);
            }
        }
Exemplo n.º 23
0
        private static bool LoadMirrorList(String sServer)
        {
            try
            {
                XmlNode node = Online_Parsing_Classes.OnlineAPI.GetMirrors(AppendAPI(sServer, true));

                if (node == null)
                {
                    return(false);
                }

                int count = 0;
                foreach (XmlNode itemNode in node.ChildNodes)
                {
                    // create a new OnlineMirror object
                    var mirror = new DBOnlineMirror();

                    foreach (XmlNode propertyNode in itemNode.ChildNodes)
                    {
                        if (mOnlineToFieldMap.ContainsKey(propertyNode.Name))
                        {
                            mirror[mOnlineToFieldMap[propertyNode.Name]] = propertyNode.InnerText;
                        }
                        else
                        {
                            mirror[propertyNode.Name] = propertyNode.InnerText;
                        }
                    }
                    count++;
                    mMemoryMirrors.Add(mirror);
                }
                MPTVSeriesLog.Write("Received " + count.ToString() + " mirror site(s) from " + sServer);
                return(true);
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write(string.Format("Error: unable to retrieve list of mirrors online: {0}", ex.Message));
                return(false);
            }
        }
Exemplo n.º 24
0
        public static bool IsAssemblyAvailable(string name, Version ver)
        {
            bool result = false;

            MPTVSeriesLog.Write(string.Format("Checking whether assembly {0} is available and loaded...", name), MPTVSeriesLog.LogLevel.Debug);

            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly a in assemblies)
            {
                try
                {
                    if (a.GetName().Name == name && a.GetName().Version >= ver)
                    {
                        MPTVSeriesLog.Write(string.Format("Assembly {0} is available and loaded.", name), MPTVSeriesLog.LogLevel.Debug);
                        result = true;
                        break;
                    }
                }
                catch
                {
                    MPTVSeriesLog.Write(string.Format("Assembly.GetName() call failed for '{0}'!\n", a.Location));
                }
            }

            if (!result)
            {
                MPTVSeriesLog.Write(string.Format("Assembly {0} is not loaded (not available?), trying to load it manually...", name), MPTVSeriesLog.LogLevel.Debug);
                try {
                    //Assembly assembly = AppDomain.CurrentDomain.Reflection(new AssemblyName(name));
                    Assembly assembly = Assembly.ReflectionOnlyLoad(name);
                    MPTVSeriesLog.Write(string.Format("Assembly {0} is available and loaded successfully.", name), MPTVSeriesLog.LogLevel.Debug);
                    result = true;
                }
                catch (Exception e) {
                    MPTVSeriesLog.Write(string.Format("Assembly {0} is unavailable, load unsuccessful: {1}:{2}", name, e.GetType(), e.Message), MPTVSeriesLog.LogLevel.Debug);
                }
            }

            return(result);
        }
Exemplo n.º 25
0
        public bool Insert(PlayListItem item, int currentItem)
        {
            bool success = false;

            if (item == null)
            {
                return(success);
            }

            MPTVSeriesLog.Write(string.Format("Playlist: Insert {0} at {1}", item.FileName, Convert.ToString(currentItem)));
            if (currentItem < _listPlayListItems.Count)
            {
                _listPlayListItems.Insert(currentItem + 1, item);
                success = true;
            }
            else
            {
                _listPlayListItems.Add(item);
                success = true;
            }
            return(success);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Read Graphics Quality Settings and Import into Database
        /// </summary>
        /// <param name="doc"></param>
        private static void GetGraphicsQuality(XmlDocument doc)
        {
            XmlNode node      = null;
            XmlNode innerNode = null;

            node = doc.DocumentElement.SelectSingleNode("/settings/graphicsquality");
            if (node != null && node.Attributes.GetNamedItem("import").Value.ToLower() == "true")
            {
                MPTVSeriesLog.Write("Loading Skin Thumbnail Graphics Quality", MPTVSeriesLog.LogLevel.Normal);

                innerNode = node.SelectSingleNode("seriesbanners");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeriesBanners, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("seriesposters");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeriesPosters, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("seriescoverflow");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeriesPosters, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("seasonbanners");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeasonBanners, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("episodethumbs");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualityEpisodeImages, innerNode.InnerText.Trim());
                }

                ImportGraphics = true;
            }
        }
Exemplo n.º 27
0
        public static bool DownloadFile(string url, string localFile)
        {
            WebClient webClient = new WebClient();

            webClient.Headers.Add("user-agent", Settings.UserAgent);

            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(localFile));
                if (!File.Exists(localFile) || ImageAllocator.LoadImageFastFromFile(localFile) == null)
                {
                    MPTVSeriesLog.Write("Downloading new file from: " + url, MPTVSeriesLog.LogLevel.Debug);
                    webClient.DownloadFile(url, localFile);
                }
                return(true);
            }
            catch (WebException)
            {
                MPTVSeriesLog.Write("File download failed from '{0}' to '{1}'", url, localFile);
                return(false);
            }
        }
Exemplo n.º 28
0
        private static void Backup()
        {
            MPTVSeriesLog.Write("Backing up database");

            string backupDirectory = Config.GetSubFolder(Config.Dir.Database, "MP-TVSeries_Backup");
            string sourceFile      = Settings.GetPath(Settings.Path.database);
            string destinationFile = Path.Combine(backupDirectory, "TVSeriesDatabase4.db3");

            try
            {
                if (!Directory.Exists(backupDirectory))
                {
                    Directory.CreateDirectory(backupDirectory);
                }

                File.Copy(sourceFile, destinationFile, true);
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("Failed to backup database. Source File = '{0}', Destination File = '{1}', Reason = '{2}'", sourceFile, destinationFile, ex.Message);
            }
        }
Exemplo n.º 29
0
        void OnPlaybackChanged(g_Player.MediaType type, int timeMovieStopped, string filename)
        {
            if (PlayBackOpWasOfConcern(g_Player.IsVideo? g_Player.MediaType.Video : g_Player.MediaType.Unknown, g_Player.CurrentFile))
            {
                if (PlayPropertyUpdater.IsBusy)
                {
                    PlayPropertyUpdater.CancelAsync();
                }
                LogPlayBackOp("changed", g_Player.CurrentFile);
                try
                {
                    #region Set Resume Point or Watched
                    double watchedAfter = DBOption.GetOptions(DBOption.cWatchedAfter);
                    if (!m_previousEpisode[DBOnlineEpisode.cWatched] &&
                        (timeMovieStopped / playlistPlayer.g_Player.Duration) > watchedAfter / 100)
                    {
                        m_previousEpisode[DBEpisode.cStopTime] = 0;
                        m_previousEpisode.Commit();
                        MPTVSeriesLog.Write("This episode counts as watched");
                        MarkEpisodeAsWatched(m_previousEpisode);
                        SetGUIProperties(true);
                    }
                    else
                    {
                        m_previousEpisode[DBEpisode.cStopTime] = timeMovieStopped;
                        m_previousEpisode.Commit();
                        SetGUIProperties(true);
                    }
                    #endregion

                    m_previousEpisode = null;
                }
                catch (Exception e)
                {
                    MPTVSeriesLog.Write("TVSeriesPlugin.VideoHandler.OnPlaybackChanged()\r\n" + e.ToString());
                }
            }
        }
Exemplo n.º 30
0
        public static DBValue GetOptions(string property)
        {
            try
            {
                lock (thisLock)
                {
                    DBValue retValue;
                    if (optionsCache.TryGetValue(property, out retValue))
                    {
                        return(retValue);
                    }

                    // ensure our sql query will be using a valid string
                    string convertedProperty = property;
                    DatabaseUtility.RemoveInvalidChars(ref convertedProperty);

                    string          sqlQuery   = "SELECT value FROM options WHERE property = '" + convertedProperty + "'";
                    SQLiteResultSet sqlResults = DBTVSeries.Execute(sqlQuery);

                    if (sqlResults.Rows.Count > 0)
                    {
                        string dbValue = DatabaseUtility.Get(sqlResults, 0, "value");

                        if (!optionsCache.ContainsKey(property))
                        {
                            optionsCache.Add(property, dbValue);
                        }

                        return(dbValue);
                    }
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("An error occurred (" + ex.Message + ").");
            }
            return(null);
        }