Skip to content

Commit

Permalink
Merge branch 'master' into embed_badges_bits
Browse files Browse the repository at this point in the history
  • Loading branch information
lay295 committed Nov 20, 2022
2 parents c49568b + 7603ec9 commit 8192d2b
Show file tree
Hide file tree
Showing 23 changed files with 671 additions and 244 deletions.
155 changes: 155 additions & 0 deletions .github/workflows/build-pr.yml
@@ -0,0 +1,155 @@
name: Build and Upload Pull Request

on:
push:
branches: [ master ]
pull_request:
types: [ opened, reopened ]

jobs:

build-gui:
runs-on: windows-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build Windows GUI
run: dotnet publish TwitchDownloaderWPF -p:PublishProfile=Windows

- name: Download File To Workspace
# You may pin to the exact commit or the version.
# uses: carlosperate/download-file-action@e85e0aa6262f13571d17a4a39687b26981c583dc
uses: carlosperate/download-file-action@v1.0.3
with:
# URL of the file to download
file-url: https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
# New filename to rename the downloaded file
file-name: ffmpeg.zip

- name: Bundle ffmpeg
run: tar xfz ffmpeg.zip --strip-components=1; copy bin/ffmpeg.exe TwitchDownloaderWPF/bin/Release/net6.0-windows/publish/win-x64/ffmpeg.exe

- name: Zip Release
uses: vimtor/action-zip@v1
with:
files: "TwitchDownloaderWPF/bin/Release/net6.0-windows/publish/win-x64"
dest: TwitchDownloader-Windows-x64.zip

- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloader-Windows-x64.zip
path: TwitchDownloader-Windows-x64.zip

build-cli:
runs-on: ubuntu-20.04
needs: [build-gui]
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore TwitchDownloaderCLI
- name: Build
run: dotnet publish TwitchDownloaderCLI -p:PublishProfile=Windows /p:DebugType=None /p:DebugSymbols=false
- name: Build
run: dotnet publish TwitchDownloaderCLI -p:PublishProfile=Linux /p:DebugType=None /p:DebugSymbols=false
- name: Build
run: dotnet publish TwitchDownloaderCLI -p:PublishProfile=LinuxAlpine /p:DebugType=None /p:DebugSymbols=false
- name: Build
run: dotnet publish TwitchDownloaderCLI -p:PublishProfile=LinuxArm /p:DebugType=None /p:DebugSymbols=false

- name: Zip Windows CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/Windows/TwitchDownloaderCLI.exe
dest: TwitchDownloaderCLI-Windows-x64.zip

- name: Zip Linux CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/Linux/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-Linux-x64.zip

- name: Zip LinuxAlpine CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/LinuxAlpine/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-LinuxAlpine-x64.zip

- name: Zip LinuxArm CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/LinuxArm/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-LinuxArm.zip



- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloaderCLI-Windows-x64.zip
path: TwitchDownloaderCLI-Windows-x64.zip

- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloaderCLI-Linux-x64.zip
path: TwitchDownloaderCLI-Linux-x64.zip

- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloaderCLI-LinuxAlpine-x64.zip
path: TwitchDownloaderCLI-LinuxAlpine-x64.zip

- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloaderCLI-LinuxArm.zip
path: TwitchDownloaderCLI-LinuxArm.zip

- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloaderCLI-LinuxArm.zip
path: TwitchDownloaderCLI-LinuxArm.zip


build-cli-mac:
runs-on: macos-latest
needs: [build-cli]
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore TwitchDownloaderCLI
- name: Build
run: dotnet publish TwitchDownloaderCLI -p:PublishProfile=MacOS /p:DebugType=None /p:DebugSymbols=false

- name: Zip Release
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/MacOS/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-MacOS-x64.zip

- name: Upload Artifact Asset
uses: actions/upload-artifact@v3
with:
name: TwitchDownloaderCLI-MacOS-x64.zip
path: TwitchDownloaderCLI-MacOS-x64.zip


40 changes: 20 additions & 20 deletions .github/workflows/build.yml
Expand Up @@ -32,7 +32,7 @@ jobs:
name: upload_url
path: upload_url.txt

build:
build-gui:
runs-on: windows-latest
needs: [create-release]
env:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
uses: vimtor/action-zip@v1
with:
files: "TwitchDownloaderWPF/bin/Release/net6.0-windows/publish/win-x64"
dest: release.zip
dest: TwitchDownloaderGUI-${{ github.event.inputs.release_tag }}-Windows-x64.zip

- name: Download URL
uses: actions/download-artifact@v2
Expand All @@ -86,13 +86,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.url.outputs.content }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: release.zip
asset_name: release.zip
asset_path: TwitchDownloaderGUI-${{ github.event.inputs.release_tag }}-Windows-x64.zip
asset_name: TwitchDownloaderGUI-${{ github.event.inputs.release_tag }}-Windows-x64.zip
asset_content_type: application/zip

build-cli:
runs-on: ubuntu-20.04
needs: [create-release, build]
needs: [create-release, build-gui]
steps:
- uses: actions/checkout@v2
- name: Setup .NET
Expand All @@ -114,25 +114,25 @@ jobs:
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/Windows/TwitchDownloaderCLI.exe
dest: TwitchDownloaderCLI-Windows-x64.zip
dest: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-Windows-x64.zip

- name: Zip Linux CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/Linux/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-Linux-x64.zip
dest: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-Linux-x64.zip

- name: Zip LinuxAlpine CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/LinuxAlpine/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-LinuxAlpine-x64.zip
dest: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-LinuxAlpine-x64.zip

- name: Zip LinuxArm CLI
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/LinuxArm/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-LinuxArm.zip
dest: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-LinuxArm.zip

- name: Download URL
uses: actions/download-artifact@v2
Expand All @@ -151,8 +151,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.url.outputs.content }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: TwitchDownloaderCLI-Windows-x64.zip
asset_name: TwitchDownloaderCLI-Windows-x64.zip
asset_path: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-Windows-x64.zip
asset_name: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-Windows-x64.zip
asset_content_type: application/zip

- name: Upload Release Asset
Expand All @@ -161,8 +161,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.url.outputs.content }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: TwitchDownloaderCLI-Linux-x64.zip
asset_name: TwitchDownloaderCLI-Linux-x64.zip
asset_path: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-Linux-x64.zip
asset_name: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-Linux-x64.zip
asset_content_type: application/zip

- name: Upload Release Asset
Expand All @@ -171,8 +171,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.url.outputs.content }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: TwitchDownloaderCLI-LinuxAlpine-x64.zip
asset_name: TwitchDownloaderCLI-LinuxAlpine-x64.zip
asset_path: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-LinuxAlpine-x64.zip
asset_name: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-LinuxAlpine-x64.zip
asset_content_type: application/zip

- name: Upload Release Asset
Expand All @@ -181,8 +181,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.url.outputs.content }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: TwitchDownloaderCLI-LinuxArm.zip
asset_name: TwitchDownloaderCLI-LinuxArm.zip
asset_path: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-LinuxArm.zip
asset_name: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-LinuxArm.zip
asset_content_type: application/zip

build-cli-mac:
Expand All @@ -203,7 +203,7 @@ jobs:
uses: vimtor/action-zip@v1
with:
files: TwitchDownloaderCLI/bin/Release/net6.0/publish/MacOS/TwitchDownloaderCLI
dest: TwitchDownloaderCLI-MacOS-x64.zip
dest: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-MacOS-x64.zip

- name: Download URL
uses: actions/download-artifact@v2
Expand All @@ -222,6 +222,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.url.outputs.content }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: TwitchDownloaderCLI-MacOS-x64.zip
asset_name: TwitchDownloaderCLI-MacOS-x64.zip
asset_path: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-MacOS-x64.zip
asset_name: TwitchDownloaderCLI-${{ github.event.inputs.release_tag }}-MacOS-x64.zip
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion TwitchDownloaderCLI/Modes/Arguments/ChatRenderArgs.cs
Expand Up @@ -45,7 +45,7 @@ public class ChatRenderArgs
[Option("outline-size", Default = 4, HelpText = "Size of outline if outline is enabled.")]
public double OutlineSize { get; set; }

[Option('f', "font", Default = "Inter", HelpText = "Font to use.")]
[Option('f', "font", Default = "Inter Embedded", HelpText = "Font to use.")]
public string Font { get; set; }

[Option("font-size", Default = 12, HelpText = "Font size.")]
Expand Down
2 changes: 1 addition & 1 deletion TwitchDownloaderCLI/Tools/PathExtensions.cs
Expand Up @@ -18,7 +18,7 @@ public static string GetFileOnPath(string fileName)
return Path.GetFullPath(fileName);
}

var environmentPath = Environment.GetEnvironmentVariable("Path");
var environmentPath = Environment.GetEnvironmentVariable("PATH"); // environment variable is case sensitive on Linux
foreach (var path in environmentPath.Split(Path.PathSeparator))
{
var fullPath = Path.Combine(path, fileName);
Expand Down
26 changes: 18 additions & 8 deletions TwitchDownloaderCore/ChatDownloader.cs
@@ -1,18 +1,16 @@
using NeoSmart.Unicode;
using NeoSmart.Unicode;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Xml.Linq;
using TwitchDownloaderCore.Options;
using TwitchDownloaderCore.TwitchObjects;

Expand Down Expand Up @@ -71,7 +69,7 @@ public async Task DownloadSection(IProgress<ProgressReport> progress, Cancellati
{
foreach (var comment in commentResponse.comments)
{
if (latestMessage < videoEnd && comment.content_offset_seconds > videoStart)
if (latestMessage < videoEnd && comment.content_offset_seconds >= videoStart)
comments.Add(comment);

latestMessage = comment.content_offset_seconds;
Expand Down Expand Up @@ -210,7 +208,7 @@ private List<Comment> ConvertComments(CommentVideo video)
newEmote.end = newEmote.begin + fragment.text.Length + 1;
emoticons.Add(newEmote);
}

newFragment.text = fragment.text;
fragments.Add(newFragment);
}
Expand Down Expand Up @@ -292,7 +290,8 @@ public async Task DownloadAsync(IProgress<ProgressReport> progress, Cancellation
{
int tc = i;
percentages.Add(0);
var taskProgress = new Progress<ProgressReport>(progressReport => {
var taskProgress = new Progress<ProgressReport>(progressReport =>
{
if (progressReport.reportType != ReportType.Percent)
{
progress.Report(progressReport);
Expand Down Expand Up @@ -509,7 +508,7 @@ public async Task DownloadAsync(IProgress<ProgressReport> progress, Cancellation

File.WriteAllText(downloadOptions.Filename, finalString.ToString(), Encoding.Unicode);
}

chatRoot = null;
GC.Collect();
}
Expand Down Expand Up @@ -586,9 +585,20 @@ private string GetMessageHtml(bool embedEmotes, Dictionary<string, EmbedEmoteDat

internal class SortedCommentComparer : IComparer<Comment>
{
// Modified from double.CompareTo
public int Compare(Comment x, Comment y)
{
return x.content_offset_seconds.CompareTo(y.content_offset_seconds);
double m_value = x.content_offset_seconds;
double value = y.content_offset_seconds;
if (m_value < value) return -1;
if (m_value > value) return 1;
if (m_value == value) return 1;

// At least one of the values is NaN.
if (double.IsNaN(m_value))
return double.IsNaN(value) ? 0 : -1;
else
return 1;
}
}
}

0 comments on commit 8192d2b

Please sign in to comment.