Ejemplo n.º 1
0
        //
        // Anime TimeSpan Handler
        //

        //This method querys AniDB and gets the TimeSpan to the next episode
        //Returns MaxTimeSpan if there is no episode
        //May return a negative Timespan if the end already aired
        public static Tuple <string, TimeSpan> GetNextEpisodeTimeSpan(string animeID)
        {
            //First we create the query Adress
            string adress = BuildAniDBQueryAdress(animeID);

            //We query the XMLDocument containing the airtimes
            XmlDocument aniDBEntry = HttpRequester.GetHttpXmlDocument(adress, DecompressionMethods.GZip);

            //AniDBEntry is null if we found no Entry
            if (aniDBEntry == null)
            {
                return(new Tuple <string, TimeSpan>("No entry", TimeSpan.MaxValue));
            }

            //We get the Anime Name
            string animeName = GetAnimeName(aniDBEntry);

            //We get the Airtime of the next episode
            DateTime nextEpisodeDate = ExtractNextDate(aniDBEntry);

            //If there is no next episode DateTime is Maxvalue
            if (nextEpisodeDate == DateTime.MaxValue)
            {
                return(new Tuple <string, TimeSpan>(animeName, TimeSpan.MaxValue));
            }

            //Calculating the Timespan to the Next Episode
            TimeSpan timeToNextEpisode = GetTimeUntilDateTime(nextEpisodeDate);

            return(new Tuple <string, TimeSpan>(animeName, timeToNextEpisode));
        }
Ejemplo n.º 2
0
        //This method returns the IDs of all Animes matching the query(animeName)
        public static List <string> GetAnimeIDs(string animeName)
        {
            //Creating List
            List <string> animeIDsList = new List <string>();

            //creating the adress for our XmlRequest to receive the IDs
            string adress = BuildIDQueryAdress(animeName);

            //Getting the IDXmlDocument
            XmlDocument aniIDXmlDocument = HttpRequester.GetHttpXmlDocument(adress);

            //adding each ID to our IDList
            //this method returns an empty list if we have found no matches
            if (aniIDXmlDocument["animetitles"] == null ||
                aniIDXmlDocument["animetitles"].ChildNodes.Count == 0)
            {
                return(animeIDsList);
            }

            //iterating over the entrys, extracting the aid
            foreach (XmlNode animeEntry in aniIDXmlDocument["animetitles"].ChildNodes)
            {
                if (animeEntry.Attributes != null &&
                    animeEntry.Attributes.GetNamedItem("aid") != null &&
                    animeEntry.Attributes.GetNamedItem("aid").Value != null)
                {
                    animeIDsList.Add(animeEntry.Attributes.GetNamedItem("aid").Value);
                }
            }

            return(animeIDsList);
        }
Ejemplo n.º 3
0
        //This method returns a link to an (random)(the last) imagefile, matching the provider and tags
        public static string GetFileLink(string tags, string provider)
        {
            string adress = AdressBuilder(tags, provider);

            //Since we can pull multiple images at once we recieve a JArray instead of a JObject
            JArray json = HttpRequester.GetHttpJSONArray(adress);

            //json is null if we messed up
            if (json == null)
            {
                return("Can not get acess to provider, provider-san is an ashole");
            }

            //jsons count is 0 if we got something but the tags found no match
            if (json.Count == 0)
            {
                return("No File matching the tags found, you are an idiot");
            }

            //we only want to get the first image, so we take the first jsonObject in the JArray (we also request only one)
            var innerJObject = json.First;

            //we extract the field "file_url" from the json, works just like XML
            string file_url = (string)innerJObject["file_url"];

            //we create a link from the relative file_url
            string fileLink = LinkBuilder(file_url, provider);

            return(fileLink);
        }
Ejemplo n.º 4
0
        public static List <Tuple <string, string> > GetAnimeManga(string tag, AnimeManga tempAnimeManga)
        {
            string      adress          = AdressBuilder(tag, tempAnimeManga);
            XmlDocument baseXmlResponse = HttpRequester.GetHttpXmlDocument(adress, "HaruhiBot", "HaruhiBot123");

            if (baseXmlResponse == null)
            {
                return(null);
            }

            return(GetAnimeMangaDictionary(tempAnimeManga, baseXmlResponse));
        }