コード例 #1
0
        private static void CreatePassportTo(string ToPath)
        {
            if (!Directory.Exists(ToPath))
            {
                return;
            }


            List <string> files = Directory.GetFiles(ToPath, EpItem.p_PassportName, SearchOption.TopDirectoryOnly).ToList();

            if (!files.Any())
            {
                List <string> movies = Directory.GetFiles(ToPath, "*.m4v", SearchOption.TopDirectoryOnly).ToList();
                if (movies.Any())
                {
                    EpItem item = new EpItem(0);
                    item.Name = Path.GetFileName(ToPath);
                    List <string> lines = EpItem.SetToPassport(item);
                    File.WriteAllLines(Path.Combine(ToPath, EpItem.p_PassportName), lines);
                }
            }

            List <string> dirs = Directory.GetDirectories(ToPath).ToList();

            foreach (var item in dirs)
            {
                CreatePassportTo(item);
            }
        }
コード例 #2
0
        internal static void UpdateItem(EpItem item)
        {
            if (!Directory.Exists(Path.GetDirectoryName(item.ItemPath)))
            {
                return;
            }
            List <string> passportData = EpItem.SetToPassport(item);

            File.WriteAllLines(item.ItemPath, passportData);
        }
コード例 #3
0
 internal static void SaveCatalog()
 {
     if (string.IsNullOrEmpty(CurrentCatalog))
     {
         return;
     }
     if (File.Exists(CurrentCatalog))
     {
         File.Copy(CurrentCatalog, Path.ChangeExtension(CurrentCatalog, "bak"), true);
     }
     System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <EpItem>));
     using (var writer = new StreamWriter(CurrentCatalog))
     {
         serializer.Serialize(writer, Source);
     }
     foreach (EpItem item in Source)
     {
         if (Directory.Exists(item.ItemDirectory))
         {
             List <string> lines = EpItem.SetToPassport(item);
             File.WriteAllLines(Path.Combine(item.ItemDirectory, EpItem.p_PassportName), lines);
         }
     }
 }
コード例 #4
0
        private static void DoTempWork1_OneCountry(string mark, string fromPath, string toPath)
        {
            string Country = mark;
            string Catalog = "MOV";
            string Studio  = string.Empty;
            string Actors  = string.Empty;
            string Serie   = string.Empty;
            int    Year    = 0;


            var files = Directory.GetFiles(fromPath, "*.m4v", SearchOption.TopDirectoryOnly).ToList();

            foreach (var fn in files)
            {
                string source = fn;
                string fnwe   = Path.GetFileName(fn);
                if (fnwe.StartsWith($"[{Country}]"))
                {
                    string newfnwe = $"{Country} {fnwe.Replace($"[{Country}]", string.Empty)}";
                    File.Move(Path.Combine(fromPath, fnwe), Path.Combine(fromPath, newfnwe));
                    fnwe   = newfnwe;
                    source = newfnwe;
                }

                if (fnwe.ToUpper().StartsWith($"{mark} "))
                {
                    string nfm = fnwe.Remove(0, 4);
                    nfm = nfm.Replace(".m4v", string.Empty);
                    nfm = nfm.Trim();
                    bool ok = false;

                    if (fnwe.ToUpper().StartsWith("$"))
                    {
                        Country = string.Empty;
                        Catalog = mark.Replace("$", string.Empty);
                        var items = nfm.Split(' ');
                        if (items[0].Contains("[") && items[0].Contains("]"))
                        {
                            Studio = items[0].Replace("[", string.Empty).Replace("]", string.Empty).Trim();
                        }

                        ok = true;
                    }
                    else
                    {
                        string yearstr = nfm.Substring(0, 4);
                        if (int.TryParse(yearstr, out Year))
                        {
                            if (Year > 1949 && Year < 2025)
                            {
                                nfm = nfm.Remove(0, 4);
                                ok  = true;
                            }
                        }
                    }

                    if (nfm.Contains("{") && nfm.Contains("}"))
                    {
                        int fi = nfm.IndexOf('{') + 1;
                        int si = nfm.IndexOf('}') - 1;
                        Actors = nfm.Substring(fi, si - fi + 1);
                        nfm    = nfm.Replace("{" + Actors + "}", string.Empty).Trim();
                    }

                    if (Catalog == "MOV" && nfm.Contains("[") && nfm.Contains("]"))
                    {
                        int fi = nfm.IndexOf('[') + 1;
                        int si = nfm.IndexOf(']') - 1;
                        Studio = nfm.Substring(fi, si - fi + 1);
                    }

                    if (Catalog == "JAV" && nfm.Contains("[") && nfm.Contains("]"))
                    {
                        Studio = string.Empty;
                        int fi = nfm.IndexOf('[') + 1;
                        int si = nfm.IndexOf(']') - 1;
                        Serie = nfm.Substring(fi, si - fi + 1);
                        nfm   = nfm.Replace("[" + Serie + "]", string.Empty).Trim();
                    }

                    if (ok)
                    {
                        string Name    = nfm.Trim();
                        string newPath = string.Empty;
                        if (Catalog == "MOV")
                        {
                            newPath = Path.Combine(toPath, Catalog, Year.ToString());
                            if (Name.Contains("-"))
                            {
                                while (Char.IsDigit(Name.Last()))
                                {
                                    Name = Name.Remove(Name.Length - 1);
                                }
                                if (Name.Last() == '-')
                                {
                                    Name = Name.Remove(Name.Length - 1);
                                }
                                Name = Name.Trim();
                            }
                        }
                        else if (Catalog == "JAV")
                        {
                            newPath = Path.Combine(toPath, Catalog, Serie);
                        }
                        else
                        {
                            newPath = Path.Combine(toPath, Catalog, Studio);
                        }


                        if (!Directory.Exists(newPath))
                        {
                            Directory.CreateDirectory(newPath);
                        }
                        if (Directory.Exists(newPath))
                        {
                            newPath = Path.Combine(newPath, Name);
                            if (!Directory.Exists(newPath))
                            {
                                Directory.CreateDirectory(newPath);
                                EpItem item = new EpItem(0);
                                item.Name    = Name;
                                item.Catalog = Catalog;
                                item.Country = Country;
                                item.Year    = Year;
                                item.Studio  = Studio;
                                item.Star    = Actors;
                                item.Serie   = Serie;
                                List <string> lines = EpItem.SetToPassport(item);
                                File.WriteAllLines(Path.Combine(newPath, EpItem.p_PassportName), lines);
                            }

                            File.Move(source, Path.Combine(newPath, Name) + ".m4v");
                        }
                    }
                }
            }
        }
コード例 #5
0
        private static void DoFOLDER(string fromPath, string toDir, List <string> parentokens)
        {
            /*
             * $01-Catalog
             * $02-Star
             * $03-Kind
             * $04-Serie
             * $05-Country
             * $06-Year
             * $07-Studio
             * $08-XRated
             * $09-Type
             * $10-Director
             * $11-NOSORT
             *
             * $JAV [JUFE] JUFE-085.m4v
             *
             * $01 JAV $02  $04  $
             * $01 JAV $04  $
             * $01 JAV $!!!JAV Movies!!!
             *
             * * $01 WEB $03 WEBCLIP $08 P $07 $
             *
             * $01 HEN $03 ARTIST COMIX $10 Georges Levis $Coco
             * $01 HEN $03 ARTIST BOARD $10 Zumi $Zumi Art
             * $01 HEN $03 ARTIST PINUP $10 Luis Royo $Luis Royo Art
             * $01 HEN $03 GameCG $07 BLACKRAINBOW $11 SORTED $!!!IMAGE SETS!!!
             *
             * $01 R3D $03 ARTIST 3D $10 Smerinka $!!!IMAGE SETS!!!
             *
             * $01 MGZ $03 ERO MAGAZIN $04 Cancans de Paris $!!!IMAGE SETS!!!
             * $01 MGZ $03 PRN MAGAZIN $04 Silwa - Backdoor Lovers $!!!IMAGE SETS!!!
             *
             * $01 COM $03 COMIX PRINTED $04 Top Model $!!!IMAGE SETS!!!
             *
             *
             * $01 MOD $03 ACTRESS $02 Eva Hedger $!!!IMAGE SETS!!!
             * $01 MOD $03 FASHION $02 Eva Hedger $!!!IMAGE SETS!!!
             * $01 MOD $03 SOFT $02 Eva Hedger $!!!IMAGE SETS!!!
             * $01 MOD $03 HARD $02 Eva Hedger $!!!IMAGE SETS!!!
             *
             */


            List <string> dirs;

            if (parentokens != null)
            {
                dirs = Directory.GetDirectories(fromPath, "*", SearchOption.TopDirectoryOnly).ToList();
            }
            else
            {
                dirs = Directory.GetDirectories(fromPath, "$*", SearchOption.TopDirectoryOnly).ToList();
            }

            foreach (var dir in dirs)
            {
                string        toPath = toDir;
                EpItem        item   = new EpItem(0);
                string        dn     = Path.GetFileName(dir);
                bool          marked = dn.Contains("$");
                List <string> tokens = dn.Split('$').ToList();
                if (!marked)
                {
                    item.Name = dn;
                    tokens    = new List <string>();
                }
                if (parentokens != null)
                {
                    tokens.AddRange(parentokens);
                }

                if (tokens.Last() == "!!!IMAGE SETS!!!")
                {
                    var files = Directory.GetFiles(dir, "*.pdf", SearchOption.TopDirectoryOnly).ToList();
                    files.AddRange(Directory.GetFiles(dir, "*.djvu", SearchOption.TopDirectoryOnly).ToList());
                    foreach (var f in files)
                    {
                        string pdfdir = Path.Combine(dir, Path.GetFileNameWithoutExtension(f));
                        Directory.CreateDirectory(pdfdir);
                        File.Move(f, Path.Combine(pdfdir, Path.GetFileName(f)));
                    }

                    tokens.Remove(tokens.Last());
                    DoFOLDER(dir, toDir, tokens);
                    Directory.Delete(dir);
                    continue;
                }
                else if (tokens.Last() == "!!!JAV Movies!!!")
                {
                    var javfiles = Directory.GetFiles(dir, "*", SearchOption.TopDirectoryOnly).ToList();
                    foreach (var jf in javfiles)
                    {
                        string   fn       = Path.GetFileNameWithoutExtension(jf);
                        string[] vals     = fn.Split('-');
                        string   jserie   = vals[0];
                        string   fullname = $"$01 JAV $04 {jserie.ToUpper()} ${fn.ToUpper()}";
                        fullname = Path.Combine(dir, fullname);
                        Directory.CreateDirectory(fullname);
                        File.Move(jf, Path.Combine(fullname, Path.GetFileName(jf)));
                    }
                    DoFOLDER(dir, toDir, null);
                    continue;
                }
                bool alreadysorted = false;
                foreach (string tok in tokens)
                {
                    if (string.IsNullOrEmpty(tok.Trim()))
                    {
                        continue;
                    }
                    string mark = tok.Substring(0, 2);
                    string val  = tok.Remove(0, 2).Trim();
                    if (mark == "01")
                    {
                        item.Catalog = val;
                    }
                    else if (mark == "02")
                    {
                        item.Star = val;
                    }
                    else if (mark == "03")
                    {
                        item.Kind = val;
                    }
                    else if (mark == "04")
                    {
                        item.Serie = val;
                    }
                    else if (mark == "05")
                    {
                        item.Country = val;
                    }
                    else if (mark == "06")
                    {
                        item.Year = Convert.ToInt32(val);
                    }
                    else if (mark == "07")
                    {
                        item.Studio = val;
                    }
                    else if (mark == "08")
                    {
                        item.XRated = val;
                    }
                    else if (mark == "09")
                    {
                        item.Type = val;
                    }
                    else if (mark == "10")
                    {
                        item.Director = val;
                    }
                    else if (mark == "11")
                    {
                        alreadysorted = (val == "SORTED");
                    }
                    else
                    {
                        item.Name = tok.Trim();
                    }
                }
                if (!string.IsNullOrEmpty(item.Name))
                {
                    if (!string.IsNullOrEmpty(item.Catalog))
                    {
                        toPath = $@"{toPath}\{item.Catalog}";
                    }
                    if (item.Catalog == "WEB")
                    {
                        if (!string.IsNullOrEmpty(item.Studio))
                        {
                            toPath = $@"{toPath}\{item.Studio}";
                        }
                    }
                    else if (item.Catalog == "MOV")
                    {
                        toPath = $@"{toPath}\{item.Year}";
                    }
                    else if (item.Catalog == "HEN" ||
                             item.Catalog == "R3D" ||
                             item.Catalog == "COM" ||
                             item.Catalog == "MOD" ||
                             item.Catalog == "MGZ")
                    {
                        if (!string.IsNullOrEmpty(item.Kind))
                        {
                            toPath = $@"{toPath}\{item.Kind}";
                        }
                        if (!string.IsNullOrEmpty(item.Director))
                        {
                            toPath = $@"{toPath}\{item.Director}";
                        }
                        if (!string.IsNullOrEmpty(item.Serie))
                        {
                            toPath = $@"{toPath}\{item.Serie}";
                        }
                        if (item.Year > 0)
                        {
                            toPath = $@"{toPath}\{item.Year}";
                        }
                        if (!string.IsNullOrEmpty(item.Star))
                        {
                            toPath = $@"{toPath}\{item.Star}";
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(item.Serie))
                        {
                            toPath = $@"{toPath}\{item.Serie}";
                        }
                    }


                    if (!Directory.Exists(toPath))
                    {
                        Directory.CreateDirectory(toPath);
                    }

                    string newname = Path.Combine(toPath, item.Name);
                    if (item.Catalog == "MOV")
                    {
                        newname = Path.Combine(toPath, $"[{item.Country}] {item.Name}");
                    }

                    if (
                        !alreadysorted &&
                        (
                            item.Catalog == "HEN" ||
                            item.Catalog == "R3D" ||
                            item.Catalog == "COM" ||
                            item.Catalog == "MOD" ||
                            item.Catalog == "MGZ"
                        ) &&
                        parentokens != null)
                    {
                        string eventsdir = Path.Combine(dir, "EVENTS");
                        Directory.CreateDirectory(eventsdir);
                        var files = Directory.GetFiles(dir, "*", SearchOption.TopDirectoryOnly).ToList();
                        files.ForEach(x => File.Move(x, Path.Combine(eventsdir, Path.GetFileName(x))));
                    }

                    try
                    {
                        if (!File.Exists(newname))
                        {
                            Directory.Move(dir, newname);
                        }
                    }
                    catch (Exception)
                    {
                    }
                    List <string> lines = EpItem.SetToPassport(item);
                    File.WriteAllLines(Path.Combine(newname, EpItem.p_PassportName), lines);
                }
            }
        }