コード例 #1
0
 internal static AdvancedSearchOptions ParseUri(UriHandlerData data)
 {
     if (data.Queries.GetBoolean("advsearch"))
     {
         return(new AdvancedSearchOptions(
                    searchName: data.Queries.GetBoolean(_SearchNameTag),
                    searchTags: data.Queries.GetBoolean(_SearchTagsTag),
                    searchDescription: data.Queries.GetBoolean(_SearchDescriptionTag),
                    searchTorrentFilenames: data.Queries.GetBoolean(_SearchTorrentFilenamesTag),
                    galleriesWithTorrentsOnly: data.Queries.GetBoolean(_GalleriesWithTorrentsOnlyTag),
                    searchLowPowerTags: data.Queries.GetBoolean(_SearchLowPowerTagsTag),
                    searchDownvotedTags: data.Queries.GetBoolean(_SearchDownvotedTagsTag),
                    showExpungedGalleries: data.Queries.GetBoolean(_ShowExpungedGalleriesTag),
                    searchMinimumRating: data.Queries.GetBoolean(_SearchMinimumRatingTag),
                    minimumRating: data.Queries.GetInt32(_MinimumRatingTag),
                    searchPageCount: data.Queries.GetBoolean(_SearchPageCountTag),
                    minimumPageCount: data.Queries.GetInt32(_MinimumPageCountTag),
                    maximumPageCount: data.Queries.GetInt32(_MaximumPageCountTag),
                    disableDefaultLanguageFilters: data.Queries.GetBoolean(_DisableDefaultLanguageFiltersTag),
                    disableDefaultUploaderFilters: data.Queries.GetBoolean(_DisableDefaultUploaderFiltersTag),
                    disableDefaultTagsFilters: data.Queries.GetBoolean(_DisableDefaultTagsFiltersTag)
                    ));
     }
     else
     {
         return(new AdvancedSearchOptions());
     }
 }
コード例 #2
0
        internal static bool TryParseGalleryPopup(UriHandlerData data, out GalleryInfo info, out GalleryLaunchStatus type)
        {
            info = default;
            type = default;
            if (data.Paths.Count < 1)
            {
                return(false);
            }
            if (!Array.Exists(_Popups, s => data.Path0.Equals(s, StringComparison.OrdinalIgnoreCase)))
            {
                return(false);
            }
            if (!long.TryParse(data.Queries.GetString("gid"), out var gId))
            {
                return(false);
            }

            var tokenstr = data.Queries.GetString("t") + data.Queries.GetString("token");

            if (!EToken.TryParse(tokenstr, out var token))
            {
                return(false);
            }
            info = new GalleryInfo(gId, token);
            type = GalleryLaunchStatus.Default;
            switch (data.Path0)
            {
            case "gallerytorrents.php":
                type = GalleryLaunchStatus.Torrent;
                break;

            case "stats.php":
                type = GalleryLaunchStatus.Stats;
                break;

            case "archiver.php":
                type = GalleryLaunchStatus.Archive;
                break;

            default:
                switch (data.Queries.GetString("act"))
                {
                case "addfav":
                    type = GalleryLaunchStatus.Favorite;
                    break;

                case "expunge":
                    type = GalleryLaunchStatus.Expunge;
                    break;

                case "rename":
                    type = GalleryLaunchStatus.Rename;
                    break;
                }
                break;
            }
            return(true);
        }
コード例 #3
0
ファイル: WatchedHandler.cs プロジェクト: steamb23/E-Viewer
        public override SearchLaunchResult Handle(UriHandlerData data)
        {
            var keyword  = GetKeyword(data);
            var category = GetCategory(data);
            var advanced = GetAdvancedSearchOptions(data);
            var sr       = Client.Current.SearchWatched(keyword, category, advanced);

            return(new SearchLaunchResult(sr));
        }
コード例 #4
0
        internal static bool TryParseGalleryPopup(UriHandlerData data, out GalleryInfo info, out GalleryLaunchStatus type)
        {
            if (data.Paths.Count == 1 &&
                (data.Path0 == "gallerytorrents.php" ||
                 data.Path0 == "gallerypopups.php" ||
                 data.Path0 == "stats.php" ||
                 data.Path0 == "archiver.php"))
            {
                if (data.Queries.TryGetValue("gid", out var gidStr) &&
                    (data.Queries.TryGetValue("t", out var gtoken) || data.Queries.TryGetValue("token", out gtoken)) &&
                    long.TryParse(data.Queries["gid"], out var gId))
                {
                    info = new GalleryInfo(gId, gtoken.ToToken());
                    type = GalleryLaunchStatus.Default;
                    switch (data.Path0)
                    {
                    case "gallerytorrents.php":
                        type = GalleryLaunchStatus.Torrent;
                        break;

                    case "stats.php":
                        type = GalleryLaunchStatus.Stats;
                        break;

                    case "archiver.php":
                        type = GalleryLaunchStatus.Archive;
                        break;

                    default:
                        if (data.Queries.TryGetValue("act", out var action))
                        {
                            switch (action)
                            {
                            case "addfav":
                                type = GalleryLaunchStatus.Favorite;
                                break;

                            case "expunge":
                                type = GalleryLaunchStatus.Expunge;
                                break;

                            case "rename":
                                type = GalleryLaunchStatus.Rename;
                                break;
                            }
                        }

                        break;
                    }
                    return(true);
                }
            }
            info = default;
            type = default;
            return(false);
        }
コード例 #5
0
ファイル: GalleryInfo.cs プロジェクト: akazakarin96/E-Viewer
        internal static bool TryParseGalleryPopup(UriHandlerData data, out GalleryInfo info, out GalleryLaunchStatus type)
        {
            info = default;
            type = default;
            if (data.Paths.Count >= 1 &&
                (data.Path0 == "gallerytorrents.php" ||
                 data.Path0 == "gallerypopups.php" ||
                 data.Path0 == "stats.php" ||
                 data.Path0 == "archiver.php"))
            {
                if (long.TryParse(data.Queries.GetString("gid"), out var gId))
                {
                    var token = data.Queries.GetString("t") + data.Queries.GetString("token");
                    if (token.IsNullOrWhiteSpace())
                    {
                        return(false);
                    }
                    info = new GalleryInfo(gId, token.ToToken());
                    type = GalleryLaunchStatus.Default;
                    switch (data.Path0)
                    {
                    case "gallerytorrents.php":
                        type = GalleryLaunchStatus.Torrent;
                        break;

                    case "stats.php":
                        type = GalleryLaunchStatus.Stats;
                        break;

                    case "archiver.php":
                        type = GalleryLaunchStatus.Archive;
                        break;

                    default:
                        switch (data.Queries.GetString("act"))
                        {
                        case "addfav":
                            type = GalleryLaunchStatus.Favorite;
                            break;

                        case "expunge":
                            type = GalleryLaunchStatus.Expunge;
                            break;

                        case "rename":
                            type = GalleryLaunchStatus.Rename;
                            break;
                        }
                        break;
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #6
0
        public static bool TryParse(Uri uri, out ImageInfo info)
        {
            var data = new UriHandlerData(uri);

            if (TryParse(data, out info))
            {
                return(true);
            }
            info = default;
            return(false);
        }
コード例 #7
0
ファイル: GalleryInfo.cs プロジェクト: akazakarin96/E-Viewer
 internal static bool TryParseGallery(UriHandlerData data, out GalleryInfo info)
 {
     if (data.Path0 == "g" && data.Paths.Count >= 3)
     {
         if (long.TryParse(data.Paths[1], out var gId))
         {
             info = new GalleryInfo(gId, data.Paths[2].ToToken());
             return(true);
         }
     }
     info = default;
     return(false);
 }
コード例 #8
0
ファイル: ImageInfo.cs プロジェクト: emmauss/ExViewer
 internal static bool TryParse(UriHandlerData data, out ImageInfo info)
 {
     if (data.Path0 == "s" && data.Paths.Count == 3)
     {
         var sp = data.Paths[2].Split('-');
         if ((sp.Length == 2) &&
             long.TryParse(sp[0], out var gID) &&
             int.TryParse(sp[1], out var pID))
         {
             info = new ImageInfo(gID, data.Paths[1].Substring(0, 10).ToToken(), pID);
             return(true);
         }
     }
     info = default(ImageInfo);
     return(false);
 }
コード例 #9
0
ファイル: GalleryInfo.cs プロジェクト: akazakarin96/E-Viewer
        public static bool TryParse(Uri uri, out GalleryInfo info)
        {
            var data = new UriHandlerData(uri);

            if (TryParseGallery(data, out info))
            {
                return(true);
            }
            if (TryParseGalleryPopup(data, out info, out _))
            {
                return(true);
            }

            info = default;
            return(false);
        }
コード例 #10
0
        public static bool TryParse(Uri uri, out FavoritesSearchResult result)
        {
            result = default;
            if (uri is null)
            {
                return(false);
            }
            var data = new UriHandlerData(uri);

            if (!FavoritesSearchHandler.Instance.CanHandle(data))
            {
                return(false);
            }
            result = (FavoritesSearchResult)FavoritesSearchHandler.Instance.Handle(data).Data;
            return(true);
        }
コード例 #11
0
 internal static bool TryParse(UriHandlerData data, out ImageInfo info)
 {
     if (data.Path0 == "s" && data.Paths.Count >= 3)
     {
         var sp = data.Paths[2].Split('-');
         if ((sp.Length == 2) &&
             long.TryParse(sp[0], out var gID) &&
             int.TryParse(sp[1], out var pID) &&
             EToken.TryParse(data.Paths[1], out var token))
         {
             info = new ImageInfo(gID, token, pID);
             return(true);
         }
     }
     info = default;
     return(false);
 }
コード例 #12
0
        public static bool TryParse(Uri uri, out CategorySearchResult result)
        {
            result = default;
            if (uri is null)
            {
                return(false);
            }
            var data = new UriHandlerData(uri);

            foreach (var handler in handlers)
            {
                if (!handler.CanHandle(data))
                {
                    continue;
                }
                result = (CategorySearchResult)handler.Handle(data).Data;
                return(true);
            }
            return(false);
        }
コード例 #13
0
        internal static AdvancedSearchOptions ParseUri(UriHandlerData data)
        {
            var advanced        = new AdvancedSearchOptions();
            var advancedEnabled = data.Queries.GetBoolean(AdvancedSearchOptionsTag);

            if (advancedEnabled)
            {
                advanced.SearchName                    = data.Queries.GetBoolean(SearchNameTag);
                advanced.SearchTags                    = data.Queries.GetBoolean(SearchTagsTag);
                advanced.SearchDescription             = data.Queries.GetBoolean(SearchDescriptionTag);
                advanced.SearchTorrentFilenames        = data.Queries.GetBoolean(SearchTorrentFilenamesTag);
                advanced.GalleriesWithTorrentsOnly     = data.Queries.GetBoolean(GalleriesWithTorrentsOnlyTag);
                advanced.SearchLowPowerTags            = data.Queries.GetBoolean(SearchLowPowerTagsTag);
                advanced.SearchDownvotedTags           = data.Queries.GetBoolean(SearchDownvotedTagsTag);
                advanced.ShowExpungedGalleries         = data.Queries.GetBoolean(ShowExpungedGalleriesTag);
                advanced.SearchMinimumRating           = data.Queries.GetBoolean(SearchMinimumRatingTag);
                advanced.MinimumRating                 = data.Queries.GetInt32(MinimumRatingTag);
                advanced.DisableDefaultLanguageFilters = data.Queries.GetBoolean(DisableDefaultLanguageFiltersTag);
                advanced.DisableDefaultUploaderFilters = data.Queries.GetBoolean(DisableDefaultUploaderFiltersTag);
            }
            advanced.SkipMasterTags = data.Queries.GetBoolean(SkipMasterTagsTag);
            return(advanced);
        }
コード例 #14
0
        internal static bool TryParseGallery(UriHandlerData data, out GalleryInfo info)
        {
            info = default;
            if (data.Paths.Count < 3)
            {
                return(false);
            }
            if (!Array.Exists(_GalleryPaths, s => data.Path0.Equals(s, StringComparison.OrdinalIgnoreCase)))
            {
                return(false);
            }
            if (!long.TryParse(data.Paths[1], out var gId))
            {
                return(false);
            }
            if (!EToken.TryParse(data.Paths[2], out var token))
            {
                return(false);
            }

            info = new GalleryInfo(gId, token);
            return(true);
        }
コード例 #15
0
ファイル: WatchedHandler.cs プロジェクト: steamb23/E-Viewer
 public override bool CanHandle(UriHandlerData data)
 {
     return(data.Paths.Count == 1 && data.Path0 == "watched");
 }