Example #1
0
        public static List <WebArtworkDetailed> FanartArtworkReader(SQLiteDataReader reader, int index, object param)
        {
            ArtworkReaderParameters args = (ArtworkReaderParameters)param;
            var list = ((IEnumerable <string>)DataReaders.ReadPipeList(reader, index)).Select(x =>
            {
                string[] parts = x.Split('?'); // ? is used as separator between filename and rating
                string path    = Path.Combine(args.DirectoryName, parts[0].Replace('/', '\\'));
                return(new WebArtworkDetailed()
                {
                    Type = args.FileType,
                    Path = path,
                    Offset = 0,
                    Filetype = Path.GetExtension(path).Substring(1),
                    Rating = String.IsNullOrEmpty(parts[1]) ? 1 :
                             (int)Math.Round(Single.Parse(parts[1].Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture) * 10),
                    Id = parts[2]
                });
            }).ToList();

            list.Sort(AnonymousComparer.FromLambda <WebArtworkDetailed>((x, y) => y.Rating - x.Rating));
            for (int i = 0; i < list.Count; i++)
            {
                list[i].Offset = i;
            }
            return(list);
        }
Example #2
0
        public static List <WebArtworkDetailed> ArtworkReader(SQLiteDataReader reader, int index, object param)
        {
            ArtworkReaderParameters args = (ArtworkReaderParameters)param;
            int i = 0;

            return(((IEnumerable <string>)DataReaders.ReadPipeList(reader, index)).Select(x =>
            {
                string path = Path.Combine(args.DirectoryName, x.Replace('/', '\\'));
                return new WebArtworkDetailed()
                {
                    Type = args.FileType,
                    Path = path,
                    Offset = i++,
                    Filetype = Path.GetExtension(path).Substring(1),
                    Rating = 1,
                    Id = path.GetHashCode().ToString()
                };
            }).ToList());
        }
Example #3
0
        public static List <WebArtworkDetailed> PreferedArtworkReader(SQLiteDataReader reader, int index, object param)
        {
            ArtworkReaderParameters args = (ArtworkReaderParameters)param;
            int i     = 0;
            var items = (IEnumerable <string>)DataReaders.ReadPipeList(reader, index);

            string preferedItem = (string)DataReaders.ReadString(reader, index + 1);

            if (!String.IsNullOrEmpty(preferedItem))
            {
                if (preferedItem.StartsWith("\\"))
                {
                    preferedItem = preferedItem.Substring(1);
                }
                if (!items.Contains(preferedItem))
                {
                    items = items.Concat(new List <string>()
                    {
                        preferedItem
                    });
                }
            }

            return(items.Select(filename =>
            {
                if (filename.StartsWith("\\"))
                {
                    filename = filename.Substring(1);
                }
                string path = Path.Combine(args.DirectoryName, filename.Replace('/', '\\'));
                return new WebArtworkDetailed()
                {
                    Type = args.FileType,
                    Path = path,
                    Offset = i++,
                    Filetype = Path.GetExtension(path).Length > 0 ? Path.GetExtension(path).Substring(1) : String.Empty,
                    Rating = filename == preferedItem ? 2 : 1,
                    Id = path.GetHashCode().ToString()
                };
            }).ToList());
        }