Ejemplo n.º 1
0
        public List <WebPicture> GetAllPictures()
        {
            List <WebPicture> pics = new List <WebPicture>();
            DBLocations       dbs  = Utils.GetMPDbLocations();
            SQLiteConnection  db   = new SQLiteConnection(SQLiteConnStr(dbs.db_pictures));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(pics);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT * FROM picture";
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                pics.Add(new WebPicture(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), reader.GetDateTime(3)));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(pics);
        }
Ejemplo n.º 2
0
        public List <WebPicture> GetAllPicturesByPath(string path)
        {
            List <WebPicture> pics = new List <WebPicture>();
            DBLocations       dbs  = Utils.GetMPDbLocations();
            SQLiteConnection  db   = new SQLiteConnection(SQLiteConnStr(dbs.db_pictures));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(pics);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT * FROM picture WHERE strFile LIKE '" + path + "%' ORDER by strFile";
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string s = reader.GetString(1);
                s = s.Remove(0, path.Length + 1);
                if (s.IndexOf('\\') == -1)
                {
                    pics.Add(new WebPicture(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), reader.GetDateTime(3)));
                }
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(pics);
        }
Ejemplo n.º 3
0
        public List <WebMusicTrack> GetAllMusicTracks(string album, string artist, string title)
        {
            List <WebMusicTrack> tracks = new List <WebMusicTrack>();
            DBLocations          dbs    = Utils.GetMPDbLocations();
            SQLiteConnection     db     = new SQLiteConnection(SQLiteConnStr(dbs.db_music));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(tracks);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT idTrack,strAlbum,strAlbumArtist,iTrack,strTitle,strPath,iDuration FROM tracks WHERE strAlbum LIKE '" + album + "%' AND strAlbumArtist LIKE '" + artist + "%' AND strTitle LIKE '" + title + "%'";
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                tracks.Add(new WebMusicTrack(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3), reader.GetString(4), reader.GetString(5), reader.GetInt32(6)));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(tracks);
        }
Ejemplo n.º 4
0
        public List <string> GetAllPicturePaths()
        {
            List <string>    paths = new List <string>();
            DBLocations      dbs   = Utils.GetMPDbLocations();
            SQLiteConnection db    = new SQLiteConnection(SQLiteConnStr(dbs.db_pictures));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(paths);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT strFile FROM picture ORDER BY strFile";
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string p = reader.GetString(0);
                if (!paths.Contains(Path.GetDirectoryName(p)))
                {
                    paths.Add(Path.GetDirectoryName(p));
                }
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(paths);
        }
Ejemplo n.º 5
0
        public List <WebMovie> GetAllMovies(string title)
        {
            List <WebMovie>  movies = new List <WebMovie>();
            DBLocations      dbs    = Utils.GetMPDbLocations();
            SQLiteConnection db     = new SQLiteConnection(SQLiteConnStr(dbs.db_movies));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(movies);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT files.idMovie,movieinfo.strGenre,movieinfo.strTitle,movieinfo.strPlot,(path.strPath || files.strFilename) as filename FROM files LEFT OUTER JOIN movieinfo ON (movieinfo.idMovie=files.idMovie) INNER JOIN path ON (path.idPath=files.idPath) WHERE movieinfo.strTitle LIKE '" + title + "%'";
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                movies.Add(new WebMovie(reader.GetInt32(0), SafeStr(reader, 1), SafeStr(reader, 2), SafeStr(reader, 3), SafeStr(reader, 4)));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(movies);
        }
Ejemplo n.º 6
0
        public WebMusicTrack GetMusicTrack(int idTrack)
        {
            WebMusicTrack    track = new WebMusicTrack();
            DBLocations      dbs   = Utils.GetMPDbLocations();
            SQLiteConnection db    = new SQLiteConnection(SQLiteConnStr(dbs.db_music));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(track);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT idTrack,strAlbum,strAlbumArtist,iTrack,strTitle,strPath,iDuration FROM tracks WHERE idTrack=" + idTrack.ToString();
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                track = new WebMusicTrack(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3), reader.GetString(4), reader.GetString(5), reader.GetInt32(6));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(track);
        }
Ejemplo n.º 7
0
        public WebMovingPicture GetMovingPicture(int id)
        {
            WebMovingPicture pic = new WebMovingPicture();
            DBLocations      dbs = Utils.GetMPDbLocations();
            SQLiteConnection db  = new SQLiteConnection(SQLiteConnStr(dbs.db_movingpictures));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(pic);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT local_media.id,title,summary,fullpath,genres,certification,year FROM local_media,local_media__movie_info,movie_info WHERE local_media.id=local_media__movie_info.local_media_id AND local_media__movie_info.movie_info_id=movie_info.id AND local_media.id=" + id.ToString();
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                pic = new WebMovingPicture(SafeInt32(reader, 0), SafeStr(reader, 1), SafeStr(reader, 2), SafeStr(reader, 3), SafeStr(reader, 4), SafeStr(reader, 5), SafeInt32(reader, 6));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(pic);
        }
Ejemplo n.º 8
0
        public WebMovie GetMovie(int idMovie)
        {
            WebMovie         movie = new WebMovie();
            DBLocations      dbs   = Utils.GetMPDbLocations();
            SQLiteConnection db    = new SQLiteConnection(SQLiteConnStr(dbs.db_movies));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(movie);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT files.idFile,movieinfo.strGenre,movieinfo.strTitle,movieinfo.strPlot,(path.strPath || files.strFilename) as filename FROM files LEFT OUTER JOIN movieinfo ON (movieinfo.idMovie=files.idMovie) INNER JOIN path ON (path.idPath=files.idPath) WHERE files.idMovie=" + idMovie.ToString();
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                movie = new WebMovie(reader.GetInt32(0), SafeStr(reader, 1), SafeStr(reader, 2), SafeStr(reader, 3), SafeStr(reader, 4));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(movie);
        }
Ejemplo n.º 9
0
        public List <WebMovingPicture> GetAllMovingPictures(string title)
        {
            List <WebMovingPicture> pics = new List <WebMovingPicture>();
            DBLocations             dbs  = Utils.GetMPDbLocations();
            SQLiteConnection        db   = new SQLiteConnection(SQLiteConnStr(dbs.db_movingpictures));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(pics);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT local_media.id,title,summary,fullpath,genres,certification,year FROM local_media,local_media__movie_info,movie_info WHERE local_media.id=local_media__movie_info.local_media_id AND local_media__movie_info.movie_info_id=movie_info.id AND title LIKE '" + title + "%'";
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                pics.Add(new WebMovingPicture(SafeInt32(reader, 0), SafeStr(reader, 1), SafeStr(reader, 2), SafeStr(reader, 3), SafeStr(reader, 4), SafeStr(reader, 5), SafeInt32(reader, 6)));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(pics);
        }
Ejemplo n.º 10
0
        public WebSeries GetTvSeries(string compositeId)
        {
            WebSeries        series = new WebSeries();
            DBLocations      dbs    = Utils.GetMPDbLocations();
            SQLiteConnection db     = new SQLiteConnection(SQLiteConnStr(dbs.db_tvseries));

            try
            {
                db.Open();
            }
            catch (Exception)
            {
                return(series);
            }
            SQLiteCommand cmd = db.CreateCommand();

            cmd.CommandText = "SELECT online_episodes.SeasonIndex,online_episodes.EpisodeIndex,online_series.pretty_name,online_episodes.EpisodeName,online_episodes.Summary,local_episodes.EpisodeFilename,local_episodes.CompositeID FROM online_series,online_episodes,local_episodes WHERE online_series.ID=online_episodes.SeriesID AND online_episodes.CompositeID=local_episodes.CompositeID AND local_episodes.CompositeID='" + compositeId + "' ORDER BY online_series.pretty_name,online_episodes.SeasonIndex,online_episodes.EpisodeIndex";
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                series = new WebSeries(SafeInt32(reader, 0), SafeInt32(reader, 1), SafeStr(reader, 2), SafeStr(reader, 3), SafeStr(reader, 4), SafeStr(reader, 5), SafeStr(reader, 6));
            }
            reader.Close(); reader.Dispose(); cmd.Dispose(); db.Close(); db.Dispose();
            return(series);
        }
Ejemplo n.º 11
0
        public static DBLocations GetMPDbLocations()
        {
            DBLocations dbLocations = new DBLocations();
            XmlDocument doc         = new XmlDocument();

            doc.Load(AppDomain.CurrentDomain.BaseDirectory + "config.xml");
            XmlNodeList dbNodes = doc.SelectNodes("/appconfig/mpdatabases/database");

            foreach (XmlNode node in dbNodes)
            {
                switch (node.Attributes["name"].Value)
                {
                case "movies":
                    dbLocations.db_movies = node.Attributes["filename"].Value;
                    break;

                case "music":
                    dbLocations.db_music = node.Attributes["filename"].Value;
                    break;

                case "pictures":
                    dbLocations.db_pictures = node.Attributes["filename"].Value;
                    break;

                case "tvseries":
                    dbLocations.db_tvseries = node.Attributes["filename"].Value;
                    break;

                case "movingpictures":
                    dbLocations.db_movingpictures = node.Attributes["filename"].Value;
                    break;
                }
            }
            return(dbLocations);
        }
Ejemplo n.º 12
0
        public SupportedMPFunctions GetSupportedMPFunctions()
        {
            DBLocations          db = Utils.GetMPDbLocations();
            SupportedMPFunctions f  = new SupportedMPFunctions();

            f.myVideos       = File.Exists(db.db_movies);
            f.myMusic        = File.Exists(db.db_music);
            f.myPictures     = File.Exists(db.db_pictures);
            f.myTvSeries     = File.Exists(db.db_tvseries);
            f.movingPictures = File.Exists(db.db_movingpictures);
            return(f);
        }
Ejemplo n.º 13
0
 public static DBLocations GetMPDbLocations()
 {
   DBLocations dbLocations = new DBLocations();
   XmlDocument doc = new XmlDocument();
   doc.Load(AppDomain.CurrentDomain.BaseDirectory + "config.xml");
   XmlNodeList dbNodes = doc.SelectNodes("/appconfig/mpdatabases/database");
   foreach (XmlNode node in dbNodes)
   {
     switch (node.Attributes["name"].Value)
     {
       case "movies":
         dbLocations.db_movies = node.Attributes["filename"].Value;
         break;
       case "music":
         dbLocations.db_music = node.Attributes["filename"].Value;
         break;
       case "pictures":
         dbLocations.db_pictures = node.Attributes["filename"].Value;
         break;
       case "tvseries":
         dbLocations.db_tvseries = node.Attributes["filename"].Value;
         break;
       case "movingpictures":
         dbLocations.db_movingpictures = node.Attributes["filename"].Value;
         break;
     }
   }
   return dbLocations;
 }