Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Jul 1, 2023
2 parents 821afff + 54709bd commit 8a3256b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Commands:
General Options:
-k, --api-key Api Key (optional)
-f, --ffmpeg-path Path to FFmpeg folder (default: ./FFmpeg)
-f, --ffmpeg-path Path to FFmpeg folder (default: <app_dir>/FFmpeg)
-i, --ignore-update Ignore new version of EthernaVideoImporter
-a, --auto-purchase Accept automatically purchase of all batches
Expand Down Expand Up @@ -77,7 +77,7 @@ Usage: evid [OPTIONS] MD_FOLDER
General Options:
-k, --api-key Api Key (optional)
-f, --ffmpeg-path Path to FFmpeg folder (default: ./FFmpeg)
-f, --ffmpeg-path Path to FFmpeg folder (default: <app_dir>/FFmpeg)
-i, --ignore-update Ignore new version of EthernaVideoImporter
-a, --auto-purchase Accept automatically purchase of all batches
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaVideoImporter.Core/CommonConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public sealed class CommonConsts
public const string BeeNodeUrl = "http://localhost/";
public const GatewayApiVersion BeeNodeGatewayVersion = GatewayApiVersion.v4_0_0;
public const DebugApiVersion BeeNodeDebugVersion = DebugApiVersion.v4_0_0;
public static readonly string DefaultFFmpegFolder = Path.Combine(".", "FFmpeg");
public static readonly string DefaultFFmpegFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FFmpeg");
public const int DownloadMaxRetry = 3;
public static readonly TimeSpan DownloadTimespanRetry = TimeSpan.FromMilliseconds(3500);
public const string EthernaCreditUrl = "https://credit.etherna.io/";
Expand Down
7 changes: 7 additions & 0 deletions src/EthernaVideoImporter.Core/EthernaVideoImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Etherna.VideoImporter.Core.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -89,6 +90,12 @@ public async Task RunAsync(
Console.WriteLine(e.Message);
throw;
}
catch (Win32Exception e)
{
Console.WriteLine($"Error opening browser on local system. Try to authenticate with API key.");
Console.WriteLine(e.Message);
throw;
}

// Get info from authenticated user.
var userEthAddress = await ethernaOpenIdConnectClient.GetEtherAddressAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>

<InvariantGlobalization>true</InvariantGlobalization>

<AssemblyName>evid</AssemblyName>
<RepositoryUrl>https://github.com/Etherna/etherna-video-importer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaVideoImporter.Devcon/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static class Program
General Options:
-k, --api-key Api Key (optional)
-f, --ffmpeg-path Path to FFmpeg folder (default: {{CommonConsts.DefaultFFmpegFolder}})
-f, --ffmpeg-path Path to FFmpeg folder (default: <app_dir>/FFmpeg)
-i, --ignore-update Ignore new version of EthernaVideoImporter
-a, --auto-purchase Accept automatically purchase of all batches
Expand Down
2 changes: 2 additions & 0 deletions src/EthernaVideoImporter/EthernaVideoImporter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>

<InvariantGlobalization>true</InvariantGlobalization>

<AssemblyName>evi</AssemblyName>
<RepositoryUrl>https://github.com/Etherna/etherna-video-importer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaVideoImporter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local Import from local videos (requires metadata descriptor, see be
General Options:
-k, --api-key Api Key (optional)
-f, --ffmpeg-path Path to FFmpeg folder (default: {{CommonConsts.DefaultFFmpegFolder}})
-f, --ffmpeg-path Path to FFmpeg folder (default: <app_dir>/FFmpeg)
-i, --ignore-update Ignore new version of EthernaVideoImporter
-a, --auto-purchase Accept automatically purchase of all batches
Expand Down
22 changes: 15 additions & 7 deletions src/EthernaVideoImporter/Services/LocalVideoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ await localVideoMetadata.SourceThumbnail.GetScaledThumbnailsAsync(CommonConsts.T

public async Task<IEnumerable<VideoMetadataBase>> GetVideosMetadataAsync()
{
var jsonMetadataFileDirectory = Path.GetDirectoryName(Path.GetFullPath(options.JsonMetadataFilePath))!;
var localVideosMetadataDto = JsonSerializer.Deserialize<List<LocalVideoMetadataDto>>(
await File.ReadAllTextAsync(options.JsonMetadataFilePath),
new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase })
await File.ReadAllTextAsync(options.JsonMetadataFilePath))
?? throw new InvalidDataException($"LocalFile wrong format in {options.JsonMetadataFilePath}");

var videosMetadataDictionary = new Dictionary<string, VideoMetadataBase>();
Expand All @@ -73,14 +73,22 @@ await File.ReadAllTextAsync(options.JsonMetadataFilePath),
ThumbnailLocalFile? thumbnail = null;
if (!string.IsNullOrWhiteSpace(metadataDto.ThumbnailFilePath))
{
using var thumbFileStream = File.OpenRead(metadataDto.ThumbnailFilePath);
var absoluteThumbnailFilePath = Path.IsPathFullyQualified(metadataDto.ThumbnailFilePath) ?
metadataDto.ThumbnailFilePath :
Path.Combine(jsonMetadataFileDirectory, metadataDto.ThumbnailFilePath);

using var thumbFileStream = File.OpenRead(absoluteThumbnailFilePath);
using var thumbManagedStream = new SKManagedStream(thumbFileStream);
using var thumbBitmap = SKBitmap.Decode(thumbManagedStream);
thumbnail = new ThumbnailLocalFile(metadataDto.ThumbnailFilePath, thumbBitmap.ByteCount, thumbBitmap.Height, thumbBitmap.Width);
thumbnail = new ThumbnailLocalFile(absoluteThumbnailFilePath, thumbBitmap.ByteCount, thumbBitmap.Height, thumbBitmap.Width);
}

// Get video info.
var ffProbeResult = GetFFProbeVideoInfo(metadataDto.VideoFilePath);
var absoluteVideoFilePath = Path.IsPathFullyQualified(metadataDto.VideoFilePath) ?
metadataDto.VideoFilePath :
Path.Combine(jsonMetadataFileDirectory, metadataDto.VideoFilePath);

var ffProbeResult = GetFFProbeVideoInfo(absoluteVideoFilePath);

videosMetadataDictionary.Add(
metadataDto.Id,
Expand All @@ -92,10 +100,10 @@ await File.ReadAllTextAsync(options.JsonMetadataFilePath),
$"{ffProbeResult.Streams.First().Height}p",
thumbnail,
new VideoLocalFile(
metadataDto.VideoFilePath,
absoluteVideoFilePath,
ffProbeResult.Streams.First().Height,
ffProbeResult.Streams.First().Width,
new FileInfo(metadataDto.VideoFilePath).Length)));
new FileInfo(absoluteVideoFilePath).Length)));

Console.WriteLine($"Loaded metadata for {metadataDto.Title}");
}
Expand Down

0 comments on commit 8a3256b

Please sign in to comment.