Example #1
0
        private static bool IsValid(JsonChaps jsonChaps)
        {
            List <JsonChapter> jsonChapters = jsonChaps.chapterInfo.chapters.chapter;
            var areAllInvalid = jsonChapters.All(IsInvalidChapter);

            return(!areAllInvalid);
        }
Example #2
0
 private static void ReplaceChapters(JsonChaps apiData, IList <Chapter> discData)
 {
     for (var i = 0; i < discData.Count; i++)
     {
         var chapter     = discData[i];
         var jsonChapter = apiData.chapterInfo.chapters.chapter[i];
         chapter.Title = jsonChapter.name;
     }
 }
Example #3
0
        private static ChapterSearchResult Transform(JsonChaps searchResult, Playlist playlist)
        {
            var jsonChapters = searchResult.chapterInfo.chapters.chapter.Take(playlist.ChapterCount).ToArray();

            return(new ChapterSearchResult
            {
                Title =
                    string.Format("+{0}: {1}", searchResult.chapterInfo.confirmations,
                                  searchResult.chapterInfo.title),
                Chapters = jsonChapters.Select(Transform).ToList()
            });
        }
Example #4
0
        private static bool IsMatch(JsonChaps jsonChaps, IList <Chapter> chapterDisc)
        {
            var chapterCountMatches = jsonChaps.chapterInfo.chapters.chapter.Count == chapterDisc.Count ||
                                      jsonChaps.chapterInfo.chapters.chapter.Count == chapterDisc.Count + 1;

            if (!chapterCountMatches)
            {
                return(false);
            }

            for (var i = 0; i < chapterDisc.Count; i++)
            {
                var discChapter = chapterDisc[i];
                var apiChapter  = jsonChaps.chapterInfo.chapters.chapter[i];
                if (!DoTimecodesMatch(discChapter.StartTime.TotalSeconds, apiChapter.time.TotalSeconds))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #5
0
        private static ChapterSearchResult Transform(JsonChaps searchResult, Playlist playlist)
        {
            var jsonChapters = searchResult.chapterInfo.chapters.chapter.Take(playlist.ChapterCount).ToArray();
            var chapters     = jsonChapters.Select(Transform).ToList();

            if (ShouldStripLeadingDigits(chapters))
            {
                StripLeadingDigits(chapters);
            }

            if (ShouldPrependChapterNumbers)
            {
                PrependChapterNumbers(chapters);
            }

            return(new ChapterSearchResult
            {
                Title =
                    string.Format("+{0}: {1}", searchResult.chapterInfo.confirmations,
                                  searchResult.chapterInfo.title),
                Chapters = chapters
            });
        }
Example #6
0
 private static ChapterSearchResult Transform(JsonChaps searchResult, Playlist playlist)
 {
     var jsonChapters = searchResult.chapterInfo.chapters.chapter.Take(playlist.ChapterCount).ToArray();
     return new ChapterSearchResult
         {
             Title =
                 string.Format("+{0}: {1}", searchResult.chapterInfo.confirmations,
                               searchResult.chapterInfo.title),
             Chapters = jsonChapters.Select(Transform).ToList()
         };
 }
Example #7
0
 private static void ReplaceChapters(JsonChaps apiData, IList<Chapter> discData)
 {
     for (var i=0; i<discData.Count; i++)
     {
         var chapter = discData[i];
         var jsonChapter = apiData.chapterInfo.chapters.chapter[i];
         chapter.Title = jsonChapter.name;
     }
 }
Example #8
0
 private static bool IsValid(JsonChaps jsonChaps)
 {
     List<JsonChapter> jsonChapters = jsonChaps.chapterInfo.chapters.chapter;
     var areAllInvalid = jsonChapters.All(IsInvalidChapter);
     return !areAllInvalid;
 }
Example #9
0
        private static bool IsMatch(JsonChaps jsonChaps, IList<Chapter> chapterDisc)
        {
            var chapterCountMatches = jsonChaps.chapterInfo.chapters.chapter.Count == chapterDisc.Count ||
                                      jsonChaps.chapterInfo.chapters.chapter.Count == chapterDisc.Count + 1;
            if (!chapterCountMatches)
                return false;

            for (var i = 0; i < chapterDisc.Count; i++)
            {
                var discChapter = chapterDisc[i];
                var apiChapter = jsonChaps.chapterInfo.chapters.chapter[i];
                if (!DoTimecodesMatch(discChapter.StartTime.TotalSeconds, apiChapter.time.TotalSeconds))
                    return false;
            }
            return true;
        }