public Task <string> GetUrlAsync(StreamInfo streamInfo) { WebDriverHandler.GainLock(); string channelUrl = string.Format(ChannelUrlFormat, streamInfo.ChannelId); string playlistUrl = GetPlaylistUrlFromPage(channelUrl); WebDriverHandler.ReleaseLock(); return(Task.FromResult(playlistUrl)); }
public Task <string> GetUrlAsync(StreamInfo streamInfo) { WebDriverHandler.GainLock(); string url = string.Format(ChannelUrlFormat, streamInfo.ChannelId); RegisterAccount(); webProcessor.GoToUrl(url); string playlistUrl = GetStreamUrlFromPageSource(); ClearResources(); return(Task.FromResult(playlistUrl)); }
public static void Main(string[] args) { IConfiguration config = LoadConfiguration(); applicationSettings = new ApplicationSettings(); nuciLoggerSettings = new NuciLoggerSettings(); config.Bind(nameof(applicationSettings), applicationSettings); config.Bind(nameof(nuciLoggerSettings), nuciLoggerSettings); Options options = Options.FromArguments(args); serviceProvider = new ServiceCollection() .AddSingleton(applicationSettings) .AddSingleton(nuciLoggerSettings) .AddSingleton(options) .AddSingleton <IRepository <ChannelStreamEntity> >(x => new XmlRepository <ChannelStreamEntity>(options.InputFile)) .AddSingleton <IFileDownloader, FileDownloader>() .AddSingleton <IPlaylistUrlRetriever, PlaylistUrlRetriever>() .AddSingleton <IPlaylistFileGenerator, PlaylistFileGenerator>() .AddSingleton <ILogger, NuciLogger>() .BuildServiceProvider(); ILogger logger = serviceProvider.GetService <ILogger>(); logger.Info(Operation.StartUp, OperationStatus.Success); try { GetPlaylist(options); } catch (AggregateException ex) { foreach (Exception innerException in ex.InnerExceptions) { logger.Fatal(Operation.Unknown, OperationStatus.Failure, innerException); } } catch (Exception ex) { logger.Fatal(Operation.Unknown, OperationStatus.Failure, ex); } finally { WebDriverHandler.CloseDriver(); } logger.Info(Operation.ShutDown, OperationStatus.Success); }
void ClearResources() { webProcessor.GoToUrl(LogOutUrl); webProcessor.Dispose(); WebDriverHandler.ReleaseLock(); }