Пример #1
0
        internal async Task <OmdbSearchResults> InternalSearchByTitleAsync(
            string search,
            OmdbSearchType resultType = OmdbSearchType.NONE,
            int?yearOfRelease         = null,
            int pageNumber            = 1)
        {
            RestRequest request = new(Method.GET);

            this.AddDefaultParameters(request);

            request.AddParameter("s", search);
            request.AddParameter("page", pageNumber);

            if (resultType is not OmdbSearchType.NONE)
            {
                request.AddParameter("type", resultType.ToQueryValue());
            }

            if (yearOfRelease is not null)
            {
                request.AddParameter("y", yearOfRelease);
            }

            return(await this.restClient.GetAsync <OmdbSearchResults>(request));
        }
Пример #2
0
 public async Task <LazyOmdbList> SearchByTitleAsync(
     string search,
     OmdbSearchType resultType = OmdbSearchType.NONE,
     int?yearOfRelease         = null
     )
 {
     return(await new LazyOmdbList(this, search, resultType, yearOfRelease).InitializeAsync());
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="client"></param>
 /// <param name="search"></param>
 /// <param name="resultType"></param>
 /// <param name="yearOfRelease"></param>
 internal LazyOmdbList(OmdbClient client, string search, OmdbSearchType resultType, int?yearOfRelease)
 {
     this._client        = client;
     this._search        = search;
     this._resultType    = resultType;
     this._yearOfRelease = yearOfRelease;
     this._omdbItems     = new();
 }
Пример #4
0
        private async Task <OmdbMovie> GetByIdOrTitleAsync(
            string?imdbId,
            string?title,
            OmdbSearchType resultType     = OmdbSearchType.NONE,
            int?yearOfRelease             = null,
            OmdbPlotOption omdbPlotOption = OmdbPlotOption.SHORT)
        {
            if (imdbId is null && title is null)
            {
                throw new ArgumentException("Both imdbId and title are null which is not allowed");
            }

            RestRequest request = new(Method.GET);

            this.AddDefaultParameters(request);

            if (imdbId is not null)
            {
                request.AddParameter("i", imdbId);
            }

            if (title is not null)
            {
                request.AddParameter("t", title);
            }

            if (resultType is not OmdbSearchType.NONE)
            {
                request.AddParameter("type", resultType.ToQueryValue());
            }

            if (yearOfRelease is not null)
            {
                request.AddParameter("y", yearOfRelease);
            }

            request.AddParameter("plot", omdbPlotOption.ToQueryValue());

            return(await this.restClient.GetAsync <OmdbMovie>(request));
        }
Пример #5
0
 public async Task <OmdbMovie> GetByMovieTitleAsync(
     string title, OmdbSearchType resultType = OmdbSearchType.NONE,
     int?yearOfRelease = null, OmdbPlotOption omdbPlotOption = OmdbPlotOption.SHORT)
 => await this.GetByIdOrTitleAsync(null, title, resultType, yearOfRelease, omdbPlotOption);
Пример #6
0
 public static string ToQueryValue(this OmdbSearchType type)
 => type switch
 {