Hls2TlgrUploader 1.0.0

dotnet add package Hls2TlgrUploader --version 1.0.0                
NuGet\Install-Package Hls2TlgrUploader -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hls2TlgrUploader" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hls2TlgrUploader --version 1.0.0                
#r "nuget: Hls2TlgrUploader, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hls2TlgrUploader as a Cake Addin
#addin nuget:?package=Hls2TlgrUploader&version=1.0.0

// Install Hls2TlgrUploader as a Cake Tool
#tool nuget:?package=Hls2TlgrUploader&version=1.0.0                

Hls2TlgrUploader

This library uploads HLS stream to Telegram channel.

How to use

  1. Add nuget package
  2. Set up your appsettings.json
  3. Register services
  4. Use IVideoUploadingService

Add nuget package

dotnet add package Hls2TlgrUploader

Set up your appsettings.json

{
    "Telegram": {
        "BotToken": "YOUR_BOT_TOKEN",
        "DestinationChatId": "YOUR_CHAT_ID_OR_CHANNEL_ALIAS"
    }
}

Register services

The package provides an extension method for IServiceCollection.

public void ConfigureServices(IServiceCollection services)
{
    services.AddHls2TlgrUploader(Configuration);
}

However, all necessary services are public, so you can register them manually.

Use IVideoUploadingService

See also Hls2TlgrUploader.IntegrationTests.

public class YourService
{
    private readonly IVideoUploadingService _videoUploadingService;

    public YourService(IVideoUploadingService videoUploadingService)
    {
        _videoUploadingService = videoUploadingService;
    }

    public async Task UploadVideoAsync()
    {
        Uri[] hlsParts = GetHlsPartsUrls();
        Task<Stream> thumbnailJpgStream = GetThumbnail();
        Message message = await service.CopyToTelegramAsync(
            uris,
            thumbnailJpgStream,
            "Some caption",
            CancellationToken.None);
    }
}

Configuration

The package uses 2 configuration sections: Telegram and Processing. You can pass a configuration object to AddHls2TlgrUploader method.

Only 2 properties are required: Telegram:BotToken and Telegram:DestinationChatId.

Available options:

  • Telegram

    • BotToken (required)
    • DestinationChatId (required)
    • ApiUrl (default: https://api.telegram.org) - Telegram API URL
    • TimeoutSeconds (default: 60) - Timeout for Telegram API requests
  • Processing

    • ConcurrentDownloads (default: 1) - Number of concurrent downloads. See Download concurrency
    • TempVideoFilePattern (default: "video-{0}.mp4") - Pattern for temporary video files. {0} is replaced with a random GUID in format "D" (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx).
    • FfmpegPath (default: "ffmpeg") - Path to ffmpeg executable

Download concurrency <a name="download-concurrency"></a>

The package can use HttpClient for downloading HLS parts. The parts are downloaded into memory and processed as they arrive.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 94 8/31/2024