Exemplo n.º 1
0
        public bool AddFavoriteVideo(VideoInfo foVideo, string titleFromUtil, string siteName)
        {
            DatabaseUtility.RemoveInvalidChars(ref siteName);
            string title   = string.IsNullOrEmpty(titleFromUtil) ? "" : DatabaseUtility.RemoveInvalidChars(titleFromUtil);
            string desc    = string.IsNullOrEmpty(foVideo.Description) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Description);
            string thumb   = string.IsNullOrEmpty(foVideo.Thumb) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Thumb);
            string url     = string.IsNullOrEmpty(foVideo.VideoUrl) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.VideoUrl);
            string length  = string.IsNullOrEmpty(foVideo.Length) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Length);
            string airdate = string.IsNullOrEmpty(foVideo.Airdate) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Airdate);
            string other   = DatabaseUtility.RemoveInvalidChars(foVideo.GetOtherAsString());

            Log.Instance.Info("inserting favorite on site '{4}' with title: '{0}', desc: '{1}', thumb: '{2}', url: '{3}'", title, desc, thumb, url, siteName);

            //check if the video is already in the favorite list
            string lsSQL = string.Format("select VDO_ID from FAVORITE_VIDEOS where VDO_SITE_ID='{0}' AND VDO_URL='{1}' and VDO_OTHER_NFO='{2}'", siteName, url, other);

            if (m_db.Execute(lsSQL).Rows.Count > 0)
            {
                Log.Instance.Info("Favorite Video '{0}' already in database", title);
                return(false);
            }

            lsSQL =
                string.Format(
                    "insert into FAVORITE_VIDEOS(VDO_NM,VDO_URL,VDO_DESC,VDO_TAGS,VDO_LENGTH,VDO_OTHER_NFO,VDO_IMG_URL,VDO_SITE_ID)VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
                    title, url, desc, airdate, length, other, thumb, siteName);
            m_db.Execute(lsSQL);
            if (m_db.ChangedRows() > 0)
            {
                Log.Instance.Info("Favorite '{0}' inserted successfully into database", foVideo.Title);
                return(true);
            }
            else
            {
                Log.Instance.Warn("Favorite '{0}' failed to insert into database", foVideo.Title);
                return(false);
            }
        }