Fixing the ordering problem (1 Viewer)

frying_fish

Portal Member
August 21, 2008
43
3
Home Country
United Kingdom United Kingdom
Hey people,


just wondering if there are any people that have also looked at the code for matching a localepisode to an online episode in Onlineparse.cs. The method is matchOnlineToLocalEpisode (starting around line 1300).

I've been looking through this over the last couple of days, and have made a little bit of progress, I have a way that works for DVD ordering, (or on what I've tried so far, I don't know how it will handle double episodes currently). I'm also currently looking at absolute ordering, I can get it to find the correct episode now and fill in the correct information with regards to the file, however in the configuration screen it is still showing them slightly wrong.

i.e. with naruto:

Naruto
- Specials
- 0x2 (corresponds to episode 002 as would expect)
- 0x56 (corresponds to episode 056)
- Season 1
- 1x2 (corresponds to episode 102)


So I'm a little confused, as its not altering the season and episode index that it first obtains, even though I thought I was changing it, I was trying to make them all have season index 1 and the episode index as their absolute number where as in the db it seems to be keeping the listed one (for display) as the ones it first parsed in.

the code for absolute is: (and if you know how to solve this issue then please say)

Code:
case "Absolute":
                                   
                    System.Globalization.NumberFormatInfo provided = new System.Globalization.NumberFormatInfo();
                    float onlineabs = -1;
                    float onlineabsTemp;
                    if (float.TryParse(onlineEpisode["absolute_number"], System.Globalization.NumberStyles.AllowDecimalPoint, provided, out onlineabsTemp))
                        onlineabs = onlineabsTemp;
                    MPTVSeriesLog.Write(string.Format("Absolute number: {0}", onlineabs));
                    if(onlineabs !=-1)
                    {
                        double localabs= -1;
                        if ((int)localEpisode[DBEpisode.cSeasonIndex] == 0)
                        {
                            /*Now we have to figure out whether we are at ep 100 or more*/
                            localabs = Convert.ToDouble(localEpisode[DBEpisode.cSeasonIndex].ToString() + localEpisode[DBEpisode.cEpisodeIndex].ToString());
                        }
                        else if((int)localEpisode[DBEpisode.cSeasonIndex] >=1 && (int)localEpisode[DBEpisode.cEpisodeIndex] < 10 )
                        {/* Any episode X0[0-9] should be combined in this manner */
                            localabs = Convert.ToDouble(localEpisode[DBEpisode.cSeasonIndex].ToString() + "0" + localEpisode[DBEpisode.cEpisodeIndex].ToString());
                        }
                        else if ((int)localEpisode[DBEpisode.cSeasonIndex] >= 1 && (int)localEpisode[DBEpisode.cEpisodeIndex] >= 10 )
                        {/* All other episodes should fall into this category */
                            localabs = Convert.ToDouble(localEpisode[DBEpisode.cSeasonIndex].ToString() + localEpisode[DBEpisode.cEpisodeIndex].ToString());
                        }
                        
                        float.TryParse(onlineEpisode["absolute_number"], System.Globalization.NumberStyles.AllowDecimalPoint, provided, out onlineabs);
                        if(localabs == onlineabs)
                        {
                            onlineEpisode[DBEpisode.cSeasonIndex] = 1;
                            onlineEpisode[DBEpisode.cEpisodeIndex] = (int)localabs;
                            MPTVSeriesLog.Write(string.Format("Matched Absolute Ep {0} to local ep {1}{2}", onlineabs, series, localEpisode ),
 MPTVSeriesLog.LogLevel.Debug);
                            return true;
                        }
                        else
                        {
                            MPTVSeriesLog.Write(string.Format("Failed to Match local ep {1}{2} to Absolute ep {0}", onlineabs, series, localEpisode ),
 MPTVSeriesLog.LogLevel.Debug);
                            return false;
                        }
                    } break;

This is clearly an early prototype but if anyone can spot any glaring errors then let me know.


also, here is my current state of DVD ordering (again its not pretty or by any means fully correct, but it seems to do the job (lots of testing, i.e. double episodes) [ it does work for firefly and futurama, where firefly - 1x01 - serenity is the name for 1.1 & 1.2]

Code:
case "DVD":
                    System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo();
                    provider.NumberDecimalSeparator = ".";
                    int localSeason = (int)localEpisode[DBEpisode.cSeasonIndex];
                    float onlineSeasonTemp;
                    int onlineSeason = -1; 
                    if( float.TryParse(onlineEpisode["DVD_season"], System.Globalization.NumberStyles.AllowDecimalPoint, provider, out onlineSeasonTemp))
                        onlineSeason = (int)onlineSeasonTemp;
                    
                    int localEp = (int)localEpisode[DBEpisode.cEpisodeIndex];
                    int localEp2 = (int)localEpisode[DBEpisode.cEpisodeIndex2];
                    
                    if (Helper.String.IsNullOrEmpty(localEpisode[DBEpisode.cEpisodeIndex2])) localEp2 = 0;
                    float onlineEp = -1;
                    
                    
                    if (onlineSeason != -1 && float.TryParse(onlineEpisode["DVD_episodenumber"], System.Globalization.NumberStyles.AllowDecimalPoint,
 provider, out onlineEp))
                    {
                        //MPTVSeriesLog.Write(string.Format("Series {0} , localEp {1} localEp2 {2} onlineEp {3}", onlineSeason, localEp, localEp2, onlineEp));
                        /*if (!Helper.String.IsNullOrEmpty(onlineEpisode["DVD_season"]) && !Helper.String.IsNullOrEmpty(onlineEpisode["DVD_season"]) &&
                            (localSeason == onlineSeason && ((int)localEp == (int)onlineEp || (int)localEp2 == -1 ? false : (int)localEp2 == (int)onlineEp)))
                        */
                        
                        //if(localEp == (int)onlineEp)
                        string localstring;
                        double localcomp;
                        localstring = (localEp.ToString() + "." + localEp2.ToString());
                        localcomp = Convert.ToDouble(localstring);
                        if(!Helper.String.IsNullOrEmpty(onlineEpisode["DVD_season"]) && !Helper.String.IsNullOrEmpty(onlineEpisode["DVD_episodenumber"])
 && (localSeason == onlineSeason && (localcomp ==  onlineEp || localEp == (int) onlineEp)))
                        {
                            /*check that the vital parts exist DVD_season and DVD_episodenumber, then check to see if we have a match either for the full
                             possible online format of X.Y via the use of localcomp and some string combinations, or through the default style of X.0 
                             via integer comparison*/
                            // overwrite onlineEps season/ep #
                            onlineEpisode[DBOnlineEpisode.cSeasonIndex] = (int)localEpisode[DBEpisode.cSeasonIndex];
                            if (localcomp == onlineEp)
                            {
                                MPTVSeriesLog.Write(string.Format("Episode {0} matched to episode {1}", localEp, onlineEp),
 MPTVSeriesLog.LogLevel.Debug );
                                onlineEpisode[DBEpisode.cEpisodeIndex] = localEp;
                            }
                            else if (localEp == (int)onlineEp)
                            {
                                onlineEpisode[DBEpisode.cEpisodeIndex] = localEp;
                            }
                            return true;
                        }
                        else
                        {
                                MPTVSeriesLog.Write(string.Format("File does not match current parse Series: {0} Episode: {1} : Online Episode: {2}",
 localSeason, localcomp, onlineEp), MPTVSeriesLog.LogLevel.Debug);
                              return false;
                        }
                        
                    } break;
 

Users who are viewing this thread

Top Bottom