using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Scraper.Storage.Filesystem;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5;
using skyscraper8.Skyscraper.IO;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Tests
{
	public class DocsisTestsLong
	{
		[Fact]
		public void TestLongBoiSingleStreams()
		{
			DirectoryInfo di = new DirectoryInfo("D:\\DocsisDemo");
			if (!di.Exists)
			{
				Debug.WriteLine("Files not available!");
				return;
			}

			FilesystemScraperStorageFactory storageFactory = new FilesystemScraperStorageFactory();
			storageFactory.Directory = "docsis_longboi";

			Passing passing = new Passing();
			passing.ScraperStorage = storageFactory.CreateScraperStroage();
			passing.MassImportDirectory(di);
		}

		[Fact]
		public void TestM3u8Stream()
		{
			FileInfo docsisM3u8 = new FileInfo("D:\\DocsisDemo\\docsis.m3u8");
			if (!docsisM3u8.Exists)
			{
				Debug.WriteLine("File not available!");
				return;
			}

			FileInfo alreadyTested = new FileInfo("docsis_m3u8_test.complete");
			if (alreadyTested.Exists)
			{
				Debug.WriteLine("Hello!");
				return;
			}


			M3U8Stream m3u8 = new M3U8Stream(docsisM3u8.FullName);

			TsContext tsContext = new TsContext();
			InMemoryScraperStorageFactory storageFactory = new InMemoryScraperStorageFactory();
			IScraperStroage scraperStorage = storageFactory.CreateScraperStroage();
			SkyscraperContext skyscraperContext = new SkyscraperContext(tsContext, null, scraperStorage);
			skyscraperContext.InitalizeFilterChain();
			skyscraperContext.IngestFromStream(m3u8);

			File.WriteAllText("docsis_m3u8_test.complete", "1");
		}

	}
}
