Ejemplo n.º 1
0
        public Contract_AnimeSeries ToContract(AnimeSeries_User userRecord, bool forceimages = false)
        {
            AniDB_Anime anime = this.GetAnime();
            List <CrossRef_AniDB_TvDBV2> tvDBCrossRefs   = this.GetCrossRefTvDBV2();
            CrossRef_AniDB_Other         movieDBCrossRef = this.CrossRefMovieDB;
            List <CrossRef_AniDB_MAL>    malDBCrossRef   = this.CrossRefMAL;
            MovieDB_Movie movie = null;

            if (movieDBCrossRef != null)
            {
                movie = movieDBCrossRef.GetMovieDB_Movie();
            }
            List <TvDB_Series> sers = new List <TvDB_Series>();

            foreach (CrossRef_AniDB_TvDBV2 xref in tvDBCrossRefs)
            {
                TvDB_Series tvser = xref.GetTvDBSeries();
                if (tvser != null)
                {
                    sers.Add(tvser);
                }
                else
                {
                    logger.Warn("You are missing database information for TvDB series: {0} - {1}", xref.TvDBID, xref.TvDBTitle);
                }
            }

            return(this.ToContract(anime, tvDBCrossRefs, movieDBCrossRef, userRecord, sers, malDBCrossRef, false, null, null, null, null, movie, forceimages));
        }
        // default constructor
        public AddCrossRef_AniDB_OtherRequest(CrossRef_AniDB_Other data)
        {
            this.AnimeID = data.AnimeID;
            this.CrossRefID = data.CrossRefID;
            this.CrossRefType = data.CrossRefType;

            string username = ServerSettings.AniDB_Username;
            if (ServerSettings.WebCache_Anonymous)
                username = Constants.AnonWebCacheUsername;

            this.Username = username;
        }
		public void Save(CrossRef_AniDB_Other obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
Ejemplo n.º 4
0
        public CrossRef_AniDB_OtherInput(JMMServer.Entities.CrossRef_AniDB_Other xref)
        {
            this.AnimeID        = xref.AnimeID;
            this.CrossRefID     = xref.CrossRefID;
            this.CrossRefSource = xref.CrossRefSource;
            this.CrossRefType   = xref.CrossRefType;

            this.Username = ServerSettings.AniDB_Username;
            if (ServerSettings.WebCache_Anonymous)
            {
                this.Username = Constants.AnonWebCacheUsername;
            }
        }
Ejemplo n.º 5
0
        public static void Send_CrossRefAniDBOther(JMMServer.Entities.CrossRef_AniDB_Other data)
        {
            if (!ServerSettings.WebCache_TvDB_Send)
            {
                return;
            }

            string uri = string.Format(@"http://{0}/api/CrossRef_AniDB_Other", azureHostBaseAddress);

            CrossRef_AniDB_OtherInput input = new CrossRef_AniDB_OtherInput(data);
            string json = JSONHelper.Serialize <CrossRef_AniDB_OtherInput>(input);

            SendData(uri, json, "POST");
        }
Ejemplo n.º 6
0
        public Contract_AnimeSeries ToContract(AnimeSeries_User userRecord, bool forceimages = false)
        {
            AniDB_Anime anime = this.GetAnime();
            List <CrossRef_AniDB_TvDBV2> tvDBCrossRefs   = this.GetCrossRefTvDBV2();
            CrossRef_AniDB_Other         movieDBCrossRef = this.CrossRefMovieDB;
            List <CrossRef_AniDB_MAL>    malDBCrossRef   = this.CrossRefMAL;

            List <TvDB_Series> sers = new List <TvDB_Series>();

            foreach (CrossRef_AniDB_TvDBV2 xref in tvDBCrossRefs)
            {
                sers.Add(xref.GetTvDBSeries());
            }

            return(this.ToContract(anime, tvDBCrossRefs, movieDBCrossRef, userRecord, sers, malDBCrossRef, false, null, null, null, null, forceimages));
        }
        public override void ProcessCommand()
        {
            try
            {
                JMMServer.Entities.CrossRef_AniDB_Other xref = RepoFactory.CrossRef_AniDB_Other.GetByID(CrossRef_AniDB_OtherID);
                if (xref == null)
                {
                    return;
                }

                AzureWebAPI.Send_CrossRefAniDBOther(xref);
            }
            catch (Exception ex)
            {
                logger.ErrorException(
                    "Error processing CommandRequest_WebCacheSendXRefAniDBOther: {0}" + ex.ToString(), ex);
                return;
            }
        }
Ejemplo n.º 8
0
        public static void LinkAniDBMovieDB(int animeID, int movieDBID, bool fromWebCache)
        {
            // check if we have this information locally
            // if not download it now

            MovieDB_Movie movie = RepoFactory.MovieDb_Movie.GetByOnlineID(movieDBID);
            if (movie == null)
            {
                // we download the series info here just so that we have the basic info in the
                // database before the queued task runs later
                UpdateMovieInfo(movieDBID, false);
                movie = RepoFactory.MovieDb_Movie.GetByOnlineID(movieDBID);
                if (movie == null) return;
            }

            // download and update series info and images
            UpdateMovieInfo(movieDBID, true);

            CrossRef_AniDB_Other xref = RepoFactory.CrossRef_AniDB_Other.GetByAnimeIDAndType(animeID, CrossRefType.MovieDB);
            if (xref == null)
                xref = new CrossRef_AniDB_Other();

            xref.AnimeID = animeID;
            if (fromWebCache)
                xref.CrossRefSource = (int) CrossRefSource.WebCache;
            else
                xref.CrossRefSource = (int) CrossRefSource.User;

            xref.CrossRefType = (int) CrossRefType.MovieDB;
            xref.CrossRefID = movieDBID.ToString();
            RepoFactory.CrossRef_AniDB_Other.Save(xref);
            AniDB_Anime.UpdateStatsByAnimeID(animeID);

            logger.Trace("Changed moviedb association: {0}", animeID);

            CommandRequest_WebCacheSendXRefAniDBOther req =
                new CommandRequest_WebCacheSendXRefAniDBOther(xref.CrossRef_AniDB_OtherID);
            req.Save();
        }
Ejemplo n.º 9
0
		public static void Send_CrossRef_AniDB_Other(CrossRef_AniDB_Other data)
		{
			if (!ServerSettings.WebCache_XRefFileEpisode_Send) return;


			string uri = string.Format("http://{0}/AddCrossRef_AniDB_Other.aspx", ServerSettings.WebCache_Address);
			AddCrossRef_AniDB_OtherRequest fhr = new AddCrossRef_AniDB_OtherRequest(data);
			string xml = fhr.ToXML();

			SendData(uri, xml);
		}
Ejemplo n.º 10
0
        public Contract_AnimeSeries ToContract(AniDB_Anime animeRec, List <CrossRef_AniDB_TvDBV2> tvDBCrossRefs, CrossRef_AniDB_Other movieDBCrossRef,
                                               AnimeSeries_User userRecord, List <TvDB_Series> tvseries, List <CrossRef_AniDB_MAL> malDBCrossRef, bool passedDefaultImages, AniDB_Anime_DefaultImage defPoster,
                                               AniDB_Anime_DefaultImage defFanart, AniDB_Anime_DefaultImage defWideBanner, List <AniDB_Anime_Title> titles, bool forceimages = false)
        {
            Contract_AnimeSeries contract = new Contract_AnimeSeries();

            contract.AniDB_ID                  = this.AniDB_ID;
            contract.AnimeGroupID              = this.AnimeGroupID;
            contract.AnimeSeriesID             = this.AnimeSeriesID;
            contract.DateTimeUpdated           = this.DateTimeUpdated;
            contract.DateTimeCreated           = this.DateTimeCreated;
            contract.DefaultAudioLanguage      = this.DefaultAudioLanguage;
            contract.DefaultSubtitleLanguage   = this.DefaultSubtitleLanguage;
            contract.LatestLocalEpisodeNumber  = this.LatestLocalEpisodeNumber;
            contract.EpisodeAddedDate          = this.EpisodeAddedDate;
            contract.MissingEpisodeCount       = this.MissingEpisodeCount;
            contract.MissingEpisodeCountGroups = this.MissingEpisodeCountGroups;
            contract.SeriesNameOverride        = this.SeriesNameOverride;



            if (userRecord == null)
            {
                contract.PlayedCount           = 0;
                contract.StoppedCount          = 0;
                contract.UnwatchedEpisodeCount = 0;
                contract.WatchedCount          = 0;
                contract.WatchedDate           = null;
                contract.WatchedEpisodeCount   = 0;
            }
            else
            {
                contract.PlayedCount           = userRecord.PlayedCount;
                contract.StoppedCount          = userRecord.StoppedCount;
                contract.UnwatchedEpisodeCount = userRecord.UnwatchedEpisodeCount;
                contract.WatchedCount          = userRecord.WatchedCount;
                contract.WatchedDate           = userRecord.WatchedDate;
                contract.WatchedEpisodeCount   = userRecord.WatchedEpisodeCount;
            }

            // get AniDB data
            contract.AniDBAnime = null;
            if (animeRec != null)
            {
                Contract_AniDBAnime animecontract = animeRec.ToContract(false, titles);

                AniDB_Anime_DefaultImage defaultPoster = null;
                if (passedDefaultImages)
                {
                    defaultPoster = defPoster;
                }
                else
                {
                    defaultPoster = animeRec.GetDefaultPoster();
                }

                if (defaultPoster == null)
                {
                    animecontract.DefaultImagePoster = null;
                }
                else
                {
                    animecontract.DefaultImagePoster = defaultPoster.ToContract();
                }

                if ((animecontract.DefaultImagePoster == null) && (forceimages))
                {
                    ImageDetails im = animeRec.GetDefaultPosterDetailsNoBlanks();
                    if (im != null)
                    {
                        animecontract.DefaultImagePoster           = new Contract_AniDB_Anime_DefaultImage();
                        animecontract.DefaultImagePoster.AnimeID   = im.ImageID;
                        animecontract.DefaultImagePoster.ImageType = (int)im.ImageType;
                    }
                }
                AniDB_Anime_DefaultImage defaultFanart = null;
                if (passedDefaultImages)
                {
                    defaultFanart = defFanart;
                }
                else
                {
                    defaultFanart = animeRec.GetDefaultFanart();
                }

                if (defaultFanart == null)
                {
                    animecontract.DefaultImageFanart = null;
                }
                else
                {
                    animecontract.DefaultImageFanart = defaultFanart.ToContract();
                }

                if ((animecontract.DefaultImagePoster == null) && (forceimages))
                {
                    ImageDetails im = animeRec.GetDefaultFanartDetailsNoBlanks();
                    if (im != null)
                    {
                        animecontract.DefaultImageFanart           = new Contract_AniDB_Anime_DefaultImage();
                        animecontract.DefaultImageFanart.AnimeID   = im.ImageID;
                        animecontract.DefaultImageFanart.ImageType = (int)im.ImageType;
                    }
                }

                AniDB_Anime_DefaultImage defaultWideBanner = null;
                if (passedDefaultImages)
                {
                    defaultWideBanner = defWideBanner;
                }
                else
                {
                    defaultWideBanner = animeRec.GetDefaultWideBanner();
                }

                if (defaultWideBanner == null)
                {
                    animecontract.DefaultImageWideBanner = null;
                }
                else
                {
                    animecontract.DefaultImageWideBanner = defaultWideBanner.ToContract();
                }

                contract.AniDBAnime = animecontract;
            }

            contract.CrossRefAniDBTvDBV2 = new List <Contract_CrossRef_AniDB_TvDBV2>();
            foreach (CrossRef_AniDB_TvDBV2 tvXref in tvDBCrossRefs)
            {
                contract.CrossRefAniDBTvDBV2.Add(tvXref.ToContract());
            }


            contract.TvDB_Series = new List <Contract_TvDB_Series>();
            foreach (TvDB_Series ser in tvseries)
            {
                contract.TvDB_Series.Add(ser.ToContract());
            }

            contract.CrossRefAniDBMovieDB = null;
            if (movieDBCrossRef != null)
            {
                contract.CrossRefAniDBMovieDB = movieDBCrossRef.ToContract();
            }

            contract.CrossRefAniDBMAL = new List <Contract_CrossRef_AniDB_MAL>();
            if (malDBCrossRef != null)
            {
                foreach (CrossRef_AniDB_MAL xref in malDBCrossRef)
                {
                    contract.CrossRefAniDBMAL.Add(xref.ToContract());
                }
            }

            return(contract);
        }