Update master to the next front. (#145)

This commit is contained in:
Zoe Roux 2023-03-11 13:19:58 +09:00 committed by GitHub
commit fa6bb695f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
647 changed files with 29130 additions and 16621 deletions

View File

@ -1,7 +0,0 @@
**/build
**/dist
src/Kyoo.WebApp/Front/nodes_modules
**/bin
**/obj
docs
tests

View File

@ -12,87 +12,3 @@ smart_tab = true
[{*.yaml,*.yml}]
indent_style = space
indent_size = 2
[*.cs]
csharp_prefer_braces = false
dotnet_diagnostic.IDE0130.severity = none
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.CA1848.severity = none
dotnet_diagnostic.CA2007.severity = none
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning
# Avoid "this." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
# Disable strange throw.
csharp_style_throw_expression = false:suggestion
# Forbid "var" everywhere
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning
csharp_style_var_elsewhere = false:warning
# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none
# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = true
# Indentation settings
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
# Modifiers
dotnet_style_readonly_field = true:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
# Naming style
dotnet_naming_symbols.privates.applicable_kinds = property,method,event,delegate
dotnet_naming_symbols.privates.applicable_accessibilities = private
dotnet_naming_style.underscore_pascal.capitalization = pascal_case
dotnet_naming_style.underscore_pascal.required_prefix = _
dotnet_naming_rule.privates_with_underscore.symbols = privates
dotnet_naming_rule.privates_with_underscore.style = underscore_pascal
dotnet_naming_rule.privates_with_underscore.severity = warning
dotnet_diagnostic.IDE1006.severity = warning
# ReSharper properties
resharper_align_multiline_binary_expressions_chain = false
resharper_csharp_empty_block_style = together_same_line
resharper_indent_nested_foreach_stmt = true
resharper_indent_nested_for_stmt = true
resharper_indent_nested_while_stmt = true
resharper_keep_existing_embedded_arrangement = false
resharper_place_accessorholder_attribute_on_same_line = true
resharper_place_simple_embedded_statement_on_same_line = false
resharper_wrap_before_arrow_with_expressions = true
resharper_xmldoc_attribute_indent = align_by_first_attribute
resharper_xmldoc_indent_child_elements = RemoveIndent
resharper_xmldoc_indent_text = RemoveIndent
# Waiting for https://github.com/dotnet/roslyn/issues/44596 to get fixed.
# file_header_template = Kyoo - A portable and vast media library solution.\nCopyright (c) Kyoo.\n\nSee AUTHORS.md and LICENSE file in the project root for full license information.\n\nKyoo is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\nany later version.\n\nKyoo is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Kyoo. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,3 +1,7 @@
TVDB__APIKEY=
THEMOVIEDB__APIKEY=
AUTHENTICATION_SECRET=
POSTGRES_USER=kyoousername
POSTGRES_PASSWORD=kyoopassword
POSTGRES_DB=kyooDB
PUBLIC_BACK_URL=http://localhost:5000

View File

@ -5,3 +5,7 @@ body:
- type: input
attributes:
label: "Kyoo's version"
- type: textarea
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?

View File

@ -1,3 +1,7 @@
name: Feature Request
description: Suggest a new feature for Kyoo (don't forget to check projects first)
labels: [enhancement]
body:
- type: textarea
attributes:
label: Feature description

View File

@ -1,58 +1,82 @@
name: Analysis
on: [push, pull_request, workflow_dispatch]
on:
push:
branches:
- master
- next
pull_request:
jobs:
analysis:
name: Static Analysis
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: ./.sonar/scanner
path: ~/.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p ./.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Wait for tests to run
cd back
mkdir -p ~/.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ~/.sonar/scanner
- name: Wait for tests to run (Push)
uses: lewagon/wait-on-check-action@master
if: github.event_name != 'pull_request'
with:
ref: ${{github.ref}}
check-name: tests
check-name: "Back tests"
repo-token: ${{secrets.GITHUB_TOKEN}}
running-workflow-name: analysis
allowed-conclusions: success,skipped,cancelled,neutral,failure
- name: Wait for tests to run (PR)
uses: lewagon/wait-on-check-action@master
if: github.event_name == 'pull_request'
with:
ref: ${{github.event.pull_request.head.sha}}
check-name: "Back tests"
repo-token: ${{secrets.GITHUB_TOKEN}}
running-workflow-name: analysis
allowed-conclusions: success,skipped,cancelled,neutral,failure
- name: Download coverage report
uses: dawidd6/action-download-artifact@v2
with:
commit: ${{env.COMMIT_SHA}}
workflow: tests.yml
github_token: ${{secrets.GITHUB_TOKEN}}
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: bash
run: |
cp -r results.xml/ coverage.xml/ back/
cd back
find . -name 'coverage.opencover.xml'
dotnet build-server shutdown
./.sonar/scanner/dotnet-sonarscanner begin \
~/.sonar/scanner/dotnet-sonarscanner begin \
-k:"AnonymusRaccoon_Kyoo" \
-o:"anonymus-raccoon" \
-d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
@ -60,6 +84,6 @@ jobs:
-d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" \
-d:sonar.cs.vstest.reportsPaths="**/TestOutputResults.xml"
dotnet build --no-incremental '-p:SkipTranscoder=true;SkipWebApp=true'
dotnet build --no-incremental '-p:SkipTranscoder=true'
./.sonar/scanner/dotnet-sonarscanner end -d:sonar.login="${{ secrets.SONAR_TOKEN }}"
~/.sonar/scanner/dotnet-sonarscanner end -d:sonar.login="${{ secrets.SONAR_TOKEN }}"

View File

@ -1,184 +0,0 @@
name: Build
on: [push, pull_request, workflow_dispatch]
jobs:
build:
name: "${{matrix.artifact}}'s Build"
runs-on: ${{matrix.os}}
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
runtime: linux-x64
artifact: linux
- os: windows-latest
runtime: win-x64
artifact: windows
- os: macOS-latest
runtime: osx-x64
artifact: macos
outputs:
version: ${{ steps.gitversion.outputs.majorMinorPatch }}
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Install ffmpeg
shell: bash
run: |
if [[ "${{runner.os}}" == "Windows" ]]; then
choco install ffmpeg-shared
elif [[ "${{runner.os}}" == "macOS" ]]; then
brew install ffmpeg
else
sudo apt-get update
sudo apt-get install -y libavutil-dev libavcodec-dev libavformat-dev
fi
- name: Enabling windows compilations tools
if: matrix.artifact == 'windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Select the project to build
shell: bash
run: |
echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] \
&& echo " -p:IncludeConsole=true -p:CheckCodingStyle=false src/Kyoo.Host.WindowsTrait" \
|| echo " -p:CheckCodingStyle=false src/Kyoo.Host.Console")" >> $GITHUB_ENV
- name: Build the app
env:
INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include
LIB: ${{env.LIB}};C:\Program Files\FFmpeg\lib
LIBPATH: ${{env.LIBPATH}};C:\Program Files\FFmpeg\lib
CFLAGS: -I/usr/local/include
LDFLAGS: -L/usr/local/lib
run: dotnet publish -r ${{matrix.runtime}} --self-contained -c Release -o dist ${{env.PROJECT}}
- name: Compression output
shell: bash
run: |
assets=kyoo_${{matrix.artifact}}
if [[ "${{runner.os}}" == "Windows" ]]; then
cd dist
cp -r "/C/Program Files/FFmpeg/bin/." .
7z a "../$assets.zip"
else
rootgrp=$([ "${{runner.os}}" == "macOS" ] && echo wheel || echo root)
sudo chown -R root:$rootgrp dist
tar -C dist -czf "$assets.tar.gz" .
fi
- uses: actions/upload-artifact@v2
with:
name: kyoo_${{matrix.artifact}}
path: |
*.zip
*.tar.gz
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.13
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.13
with:
useConfigFile: true
windows_release:
name: Create windows release
runs-on: windows-latest
needs: build
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'tags') }}
env:
version: ${{ needs.build.outputs.version }}
steps:
- uses: actions/checkout@v1
- name: Download windows build
uses: actions/download-artifact@v2
with:
name: kyoo_windows
path: artifact
- name: Unzip windows files
run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win
- name: Install Inno Setup
shell: cmd
run: |
curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe
innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1)
- name: Create windows installer
shell: bash
run: iscc -Dkyoo=$(realpath dist_win) -Dversion=${version} -O./ -Fkyoo-windows deployment/kyoo-windows.iss
- uses: actions/upload-artifact@v2
with:
name: kyoo_windows_installer
path: ./kyoo-windows.exe
release:
name: Create debian, rpm & arch releases
runs-on: ubuntu-latest
needs: build
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'tags') }}
env:
description: "A portable and vast media library solution."
version: ${{ needs.build.outputs.version }}
steps:
- uses: actions/checkout@v1
- name: Download linux build
uses: actions/download-artifact@v2
with:
name: kyoo_linux
path: artifact
- name: Unzip the published files.
run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz
- name: Create the package structure
run: |
sudo mkdir -p pkg/usr/lib/
sudo cp -r --no-preserve ownership dist pkg/usr/lib/kyoo
sudo install -Dm 644 deployment/kyoo.service -t pkg/usr/lib/systemd/system/
sudo install -Dm 644 deployment/kyoo.sysusers pkg/usr/lib/sysusers.d/kyoo.conf
sudo install -Dm 644 deployment/kyoo.tmpfiles pkg/usr/lib/tmpfiles.d/kyoo.conf
- name: Build debian package
uses: jiro4989/build-deb-action@v2
with:
package: kyoo
package_root: pkg
maintainer: Zoe Roux <zoe.roux@sdg.moe>
version: ${{env.version}}
depends: "libavutil-dev, libavcodec-dev, libavformat-dev"
arch: amd64
desc: ${{env.description}}
- name: Build rpm package
run: |
mkdir out
sudo rm -rf pkg/DEBIAN
rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" --define "version_ ${version}" deployment/kyoo.spec
- name: Prepare arch package
run: |
mkdir deployment/output
sed -i s/\$version/${version}/ deployment/PKGBUILD #doing the substitution here since the pkgbuild is run in a docker without env
cp -a pkg/usr deployment/output/usr
- uses: edlanglois/pkgbuild-action@v1
id: makepkg
with:
pkgdir: deployment
namcapDisable: true
- uses: actions/upload-artifact@v2
with:
name: kyoo_rpm
path: ./rpm/x86_64/*.rpm
- uses: actions/upload-artifact@v2
with:
name: kyoo_debian
path: ./*.deb
- uses: actions/upload-artifact@v2
with:
name: kyoo_arch
path: ${{steps.makepkg.outputs.pkgfile0}}

View File

@ -1,15 +1,43 @@
name: CodingStyle
name: Coding Style
on: [pull_request, workflow_dispatch]
jobs:
build:
name: "Coding style check"
back:
name: "Lint Back"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Build the app
run: dotnet build -p:CheckCodingStyle=true -p:TreatWarningsAsErrors=true '-p:SkipTranscoder=true;SkipWebApp=true'
run: cd back && dotnet build -p:CheckCodingStyle=true -p:TreatWarningsAsErrors=true '-p:SkipTranscoder=true'
front:
name: "Lint Front"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
steps:
- uses: actions/checkout@v1
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --immutable
- name: Lint
run: yarn lint

View File

@ -1,37 +1,65 @@
name: Docker
on: [push, pull_request, workflow_dispatch]
on:
push:
branches:
- master
- next
pull_request:
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
include:
- context: ./back
label: back
image: ghcr.io/${{github.repository_owner}}/kyoo_back
- context: ./front
label: front
image: ghcr.io/${{github.repository_owner}}/kyoo_front
name: Build ${{matrix.label}}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v2
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{github.repository_owner}}/Kyoo
images: ${{matrix.image}}
tags: |
type=ref,event=tag
type=edge
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Check if a package should be pushed
run: |
echo "SHOULD_PUSH=$([ "${GITHUB_REF##*/}" == "master" ] || [ "${GITHUB_REF##*/}" == "next" ] && echo "true" || echo "false")" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.repository_owner}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
context: ${{matrix.context}}
build-args: |
VERSION=0.0.0
push: ${{env.SHOULD_PUSH}}
tags: ${{steps.meta.outputs.tags}}

View File

@ -1,4 +1,4 @@
name: Update the documentation
name: Documentation
on:
push:
@ -6,8 +6,9 @@ on:
- master
jobs:
Building:
runs-on: [ubuntu-latest]
doc:
name: Update the documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: nikeee/docfx-action@v1.0.0
@ -29,4 +30,4 @@ jobs:
git push --force origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: "github.com/AnonymusRaccoon/Kyoo"
GITHUB_REPO: "github.com/${{github.repository_owner}}/Kyoo"

60
.github/workflows/native-build.yml vendored Normal file
View File

@ -0,0 +1,60 @@
name: Native build
on:
push:
branches:
- master
- next
pull_request:
jobs:
update:
name: Expo Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check for EXPO_TOKEN
run: |
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn
cache-dependency-path: front/yarn.lock
- name: Setup Expo
uses: expo/expo-github-action@v7
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies
run: yarn install --immutable
- name: Build Mobile Release
run: yarn build:mobile | tee log.txt
- name: Parse Asset URL
id: url
run: |
ASSET_URL=$(grep -oe 'https://expo.dev/artifacts/eas/.*' log.txt)
echo The android url is $ASSET_URL
echo "assetUrl=$ASSET_URL" >> $GITHUB_OUTPUT
- name: Download APK Asset
run: wget -O kyoo.apk ${{ steps.url.outputs.assetUrl }}
- uses: actions/upload-artifact@v2
with:
name: kyoo.apk
path: ./front/kyoo.apk

44
.github/workflows/native-update.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Native update
on:
push:
branches:
- master
- next
jobs:
update:
name: Expo Update
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check for EXPO_TOKEN
run: |
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn
cache-dependency-path: front/yarn.lock
- name: Setup Expo
uses: expo/expo-github-action@v7
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies
run: yarn install --immutable
- name: Publish update
run: yarn update

View File

@ -8,6 +8,7 @@ on:
jobs:
release:
name: Release a new version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -24,18 +25,9 @@ jobs:
uses: dawidd6/action-download-artifact@v2
with:
commit: ${{env.COMMIT_SHA}}
workflow: build.yml
workflow: native-build.yml
path: ./artifacts
github_token: ${{secrets.GITHUB_TOKEN}}
# - name: Public the abstractions to nuget
# id: publish_nuget
# uses: rohith/publish-nuget@v2
# with:
# PROJECT_FILE_PATH: Kyoo.Abstractions/Kyoo.Abstractions.csproj
# PACKAGE_NAME: Kyoo.Abstractions
# VERSION_REGEX: ^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$
# NUGET_KEY: ${{secrets.NUGET_API_KEY}}
# INCLUDE_SYMBOLS: true
- name: Create Release
uses: ncipollo/release-action@v1
with:

View File

@ -1,31 +1,49 @@
name: RobotTests
on: [push, pull_request, workflow_dispatch]
on:
push:
branches:
- master
- next
pull_request:
jobs:
build:
test:
name: Run Robot Tests
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Pull images
run: docker-compose pull
- name: Docker cache
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
- name: Build the app
run: docker-compose build
- name: Start the service
run: docker-compose up -d
run: |
cp .env.example .env
docker-compose up -d
- name: Perform healthchecks
run: |
docker-compose ps -a
wget --retry-connrefused http://localhost:5000 # /healthcheck
wget --retry-connrefused --retry-on-http-error=502 http://localhost:8901 #/api/healthcheck
- name: Run robot tests
run: |
pip install -r tests/robot/requirements.txt
robot -d out tests/robot/
pip install -r back/tests/robot/requirements.txt
robot -d out back/tests/robot/
- name: Show logs
if: failure()
run: docker-compose logs
- uses: actions/upload-artifact@v2
with:

View File

@ -1,11 +1,15 @@
name: Testing
on: [push, pull_request]
on:
push:
branches:
- master
- next
pull_request:
jobs:
tests:
name: Back tests
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
container: mcr.microsoft.com/dotnet/sdk:6.0
services:
postgres:
@ -21,27 +25,33 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Restore dependencies
run: dotnet restore
- name: Build
run: |
dotnet build --no-restore '-p:SkipWebApp=true;SkipTranscoder=true' -p:CopyLocalLockFileAssemblies=true
cp ./src/Kyoo.Abstractions/bin/Debug/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll ./tests/Kyoo.Tests/bin/Debug/net6.0/
cd back
dotnet build '-p:SkipTranscoder=true' -p:CopyLocalLockFileAssemblies=true
cp ./out/bin/Kyoo.Abstractions/Debug/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll ./tests/Kyoo.Tests/bin/Debug/net6.0/
- name: Test
run: dotnet test --no-build '-p:CollectCoverage=true;CoverletOutputFormat=opencover' --logger "trx;LogFileName=TestOutputResults.xml"
run: |
cd back
dotnet test --no-build '-p:CollectCoverage=true;CoverletOutputFormat=opencover' --logger "trx;LogFileName=TestOutputResults.xml"
env:
POSTGRES_HOST: postgres
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
- name: Sanitize coverage output
if: ${{ always() }}
run: sed -i "s'$(pwd)'.'" tests/Kyoo.Tests/coverage.opencover.xml
run: sed -i "s'$(pwd)/back'.'" back/tests/Kyoo.Tests/coverage.opencover.xml
- name: Upload tests results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: results.xml
path: "**/TestOutputResults.xml"
- name: Upload coverage report
if: ${{ always() }}
uses: actions/upload-artifact@v2

362
.gitignore vendored
View File

@ -1,359 +1,7 @@
## PROJECT CUSTOM IGNORES
# Transcoder build (auto generated from Kyoo.Transcoder sub-project)
Kyoo/Transcoder/Kyoo.Transcoder.dll
Kyoo/Transcoder/Kyoo.Transcoder.ilk
Kyoo/Transcoder/Kyoo.Transcoder.lib
Kyoo/Transcoder/Kyoo.Transcoder.pdb
Kyoo/Transcoder/Kyoo.Transcoder.exp
libtranscoder.so
libtranscoder.dylib
transcoder.dll
video
/video
.env
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- Backup*.rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
/Kyoo/TheTVDB-Credentials.json
.idea
.vscode
.netcoredbg_hist
log.html
output.xml
report.html

View File

@ -1,27 +0,0 @@
FROM gcc:latest as transcoder
RUN apt-get update && apt-get install -y cmake make libavutil-dev libavcodec-dev libavformat-dev
WORKDIR /transcoder
COPY src/Kyoo.Transcoder .
RUN cmake . && make -j
FROM node:14-alpine as webapp
WORKDIR /webapp
COPY front .
RUN npm install -g @angular/cli
RUN yarn install --frozen-lockfile
RUN yarn run build --configuration production
FROM mcr.microsoft.com/dotnet/sdk:6.0 as builder
WORKDIR /kyoo
COPY .git/ ./.git/
COPY . .
RUN dotnet publish -c Release -o /opt/kyoo '-p:SkipWebApp=true;SkipTranscoder=true;CheckCodingStyle=false' src/Kyoo.Host.Console
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y libavutil-dev libavcodec-dev libavformat-dev
EXPOSE 5000
COPY --from=builder /opt/kyoo /usr/lib/kyoo
COPY --from=transcoder /transcoder/libtranscoder.so /usr/lib/kyoo
COPY --from=webapp /webapp/dist/* /usr/lib/kyoo/wwwroot/
CMD ["/usr/lib/kyoo/Kyoo.Host.Console"]

View File

@ -1,5 +0,0 @@
mode: Mainline
branches: {}
ignore:
sha: []
merge-message-formats: {}

View File

@ -49,7 +49,6 @@ services:
restart: on-failure
environment:
- KYOO_DATADIR=/var/lib/kyoo
- BASICS__PUBLICURL=https://demo.kyoo.moe
- DATABASE__ENABLED=postgres
- DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres
- DATABASE__CONFIGURATIONS__POSTGRES__USER ID=kyoo

18
back/.dockerignore Normal file
View File

@ -0,0 +1,18 @@
Dockerfile
Dockerfile.dev
.dockerignore
.gitignore
docker-compose.yml
README.md
**/build
**/dist
src/Kyoo.WebApp/Front/nodes_modules
**/bin
**/obj
out
docs
tests
!tests/Kyoo.Tests/Kyoo.Tests.csproj
front
video
nginx.conf.template

94
back/.editorconfig Normal file
View File

@ -0,0 +1,94 @@
root = false
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = tab
smart_tab = true
[*.cs]
csharp_prefer_braces = false
dotnet_diagnostic.IDE0130.severity = none
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.CA1848.severity = none
dotnet_diagnostic.CA2007.severity = none
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning
# Avoid "this." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
# Disable strange throw.
csharp_style_throw_expression = false:suggestion
# Forbid "var" everywhere
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning
csharp_style_var_elsewhere = false:warning
# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none
# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = true
# Indentation settings
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
# Modifiers
dotnet_style_readonly_field = true:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
# Naming style
dotnet_naming_symbols.privates.applicable_kinds = property,method,event,delegate
dotnet_naming_symbols.privates.applicable_accessibilities = private
dotnet_naming_style.underscore_pascal.capitalization = pascal_case
dotnet_naming_style.underscore_pascal.required_prefix = _
dotnet_naming_rule.privates_with_underscore.symbols = privates
dotnet_naming_rule.privates_with_underscore.style = underscore_pascal
dotnet_naming_rule.privates_with_underscore.severity = warning
dotnet_diagnostic.IDE1006.severity = warning
# ReSharper properties
resharper_align_multiline_binary_expressions_chain = false
resharper_csharp_empty_block_style = together_same_line
resharper_indent_nested_foreach_stmt = true
resharper_indent_nested_for_stmt = true
resharper_indent_nested_while_stmt = true
resharper_keep_existing_embedded_arrangement = false
resharper_place_accessorholder_attribute_on_same_line = true
resharper_place_simple_embedded_statement_on_same_line = false
resharper_wrap_before_arrow_with_expressions = true
resharper_xmldoc_attribute_indent = align_by_first_attribute
resharper_xmldoc_indent_child_elements = RemoveIndent
resharper_xmldoc_indent_text = RemoveIndent
# Waiting for https://github.com/dotnet/roslyn/issues/44596 to get fixed.
# file_header_template = Kyoo - A portable and vast media library solution.\nCopyright (c) Kyoo.\n\nSee AUTHORS.md and LICENSE file in the project root for full license information.\n\nKyoo is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\nany later version.\n\nKyoo is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Kyoo. If not, see <https://www.gnu.org/licenses/>.

352
back/.gitignore vendored Normal file
View File

@ -0,0 +1,352 @@
out
libtranscoder.so
libtranscoder.dylib
transcoder.dll
video
.env
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- Backup*.rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
/Kyoo/TheTVDB-Credentials.json
.vscode
.netcoredbg_hist

37
back/Dockerfile Normal file
View File

@ -0,0 +1,37 @@
FROM gcc:latest as transcoder
RUN apt-get update && apt-get install -y cmake make libavutil-dev libavcodec-dev libavformat-dev
WORKDIR /transcoder
COPY src/Kyoo.Transcoder .
RUN cmake . && make -j
FROM mcr.microsoft.com/dotnet/sdk:6.0 as builder
WORKDIR /kyoo
COPY Kyoo.sln ./Kyoo.sln
COPY nuget.config ./nuget.config
COPY src/Directory.Build.props src/Directory.Build.props
COPY src/Kyoo.Authentication/Kyoo.Authentication.csproj src/Kyoo.Authentication/Kyoo.Authentication.csproj
COPY src/Kyoo.Database/Kyoo.Database.csproj src/Kyoo.Database/Kyoo.Database.csproj
COPY src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj
COPY src/Kyoo.SqLite/Kyoo.SqLite.csproj src/Kyoo.SqLite/Kyoo.SqLite.csproj
COPY src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj
COPY src/Kyoo.Abstractions/Kyoo.Abstractions.csproj src/Kyoo.Abstractions/Kyoo.Abstractions.csproj
COPY src/Kyoo.Core/Kyoo.Core.csproj src/Kyoo.Core/Kyoo.Core.csproj
COPY src/Kyoo.Host.Console/Kyoo.Host.Console.csproj src/Kyoo.Host.Console/Kyoo.Host.Console.csproj
COPY src/Kyoo.Postgresql/Kyoo.Postgresql.csproj src/Kyoo.Postgresql/Kyoo.Postgresql.csproj
COPY src/Kyoo.Swagger/Kyoo.Swagger.csproj src/Kyoo.Swagger/Kyoo.Swagger.csproj
COPY src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
COPY tests/Kyoo.Tests/Kyoo.Tests.csproj tests/Kyoo.Tests/Kyoo.Tests.csproj
RUN dotnet restore
COPY . .
ARG VERSION
RUN dotnet publish --no-restore -c Release -o /opt/kyoo "-p:Version=${VERSION:-"0.0.0-dev"};SkipTranscoder=true" src/Kyoo.Host.Console
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y libavutil-dev libavcodec-dev libavformat-dev
EXPOSE 5000
COPY --from=builder /opt/kyoo /usr/lib/kyoo
COPY --from=transcoder /transcoder/libtranscoder.so /usr/lib/kyoo
CMD ["/usr/lib/kyoo/Kyoo.Host.Console"]

35
back/Dockerfile.dev Normal file
View File

@ -0,0 +1,35 @@
FROM gcc:latest as transcoder
RUN apt-get update && apt-get install -y cmake make libavutil-dev libavcodec-dev libavformat-dev
WORKDIR /transcoder
COPY src/Kyoo.Transcoder .
RUN cmake . && make -j
FROM mcr.microsoft.com/dotnet/sdk:6.0
RUN apt-get update && apt-get install -y libavutil-dev libavcodec-dev libavformat-dev
WORKDIR /app
COPY Kyoo.sln ./Kyoo.sln
COPY nuget.config ./nuget.config
COPY src/Directory.Build.props src/Directory.Build.props
COPY src/Kyoo.Authentication/Kyoo.Authentication.csproj src/Kyoo.Authentication/Kyoo.Authentication.csproj
COPY src/Kyoo.Database/Kyoo.Database.csproj src/Kyoo.Database/Kyoo.Database.csproj
COPY src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj
COPY src/Kyoo.SqLite/Kyoo.SqLite.csproj src/Kyoo.SqLite/Kyoo.SqLite.csproj
COPY src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj
COPY src/Kyoo.Abstractions/Kyoo.Abstractions.csproj src/Kyoo.Abstractions/Kyoo.Abstractions.csproj
COPY src/Kyoo.Core/Kyoo.Core.csproj src/Kyoo.Core/Kyoo.Core.csproj
COPY src/Kyoo.Host.Console/Kyoo.Host.Console.csproj src/Kyoo.Host.Console/Kyoo.Host.Console.csproj
COPY src/Kyoo.Postgresql/Kyoo.Postgresql.csproj src/Kyoo.Postgresql/Kyoo.Postgresql.csproj
COPY src/Kyoo.Swagger/Kyoo.Swagger.csproj src/Kyoo.Swagger/Kyoo.Swagger.csproj
COPY src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
COPY tests/Kyoo.Tests/Kyoo.Tests.csproj tests/Kyoo.Tests/Kyoo.Tests.csproj
RUN dotnet restore
COPY --from=transcoder /transcoder/libtranscoder.so /usr/lib/
EXPOSE 5000
ENV DOTNET_USE_POLLING_FILE_WATCHER 1
CMD ["dotnet", "watch", "run", "--no-restore", "--project", "src/Kyoo.Host.Console"]

View File

@ -17,10 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.TheMovieDb", "src\Kyoo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Tests", "tests\Kyoo.Tests\Kyoo.Tests.csproj", "{0C8AA7EA-E723-4532-852F-35AA4E8AFED5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.WebApp", "src\Kyoo.WebApp\Kyoo.WebApp.csproj", "{2374D500-1ADB-4752-85DB-8BB0DDF5A8E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.WindowsTrait", "src\Kyoo.Host.WindowsTrait\Kyoo.Host.WindowsTrait.csproj", "{98851001-40DD-46A6-94B3-2F8D90722076}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.Console", "src\Kyoo.Host.Console\Kyoo.Host.Console.csproj", "{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Swagger", "src\Kyoo.Swagger\Kyoo.Swagger.csproj", "{7D1A7596-73F6-4D35-842E-A5AD9C620596}"
@ -85,10 +81,6 @@ Global
{4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Release|Any CPU.Build.0 = Release|Any CPU
{98851001-40DD-46A6-94B3-2F8D90722076}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98851001-40DD-46A6-94B3-2F8D90722076}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98851001-40DD-46A6-94B3-2F8D90722076}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98851001-40DD-46A6-94B3-2F8D90722076}.Release|Any CPU.Build.0 = Release|Any CPU
{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -110,7 +102,6 @@ Global
{3213C96D-0BF3-460B-A8B5-B9977229408A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67}
{6515380E-1E57-42DA-B6E3-E1C8A848818A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67}
{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
{98851001-40DD-46A6-94B3-2F8D90722076} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
{0938459E-2E2B-457F-8120-7D8CA93866A6} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
EndGlobalSection
EndGlobal

BIN
back/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@ -18,25 +18,29 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ApplicationIcon>$(MSBuildThisFileDirectory)../icons/icon-256x256.ico</ApplicationIcon>
<ApplicationIcon>$(MSBuildThisFileDirectory)../icon.ico</ApplicationIcon>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<BaseIntermediateOutputPath>$(MsBuildThisFileDirectory)/../out/obj/$(MSBuildProjectName)</BaseIntermediateOutputPath>
<BaseOutputPath>$(MsBuildThisFileDirectory)/../out/bin/$(MSBuildProjectName)</BaseOutputPath>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
<!-- This is horrible but the only workarround I found to disable the transcoder copy on the dev dockerfile -->
<SkipTranscoder Condition="$(MsBuildThisFileDirectory) == '/app/src/'">true</SkipTranscoder>
<CheckCodingStyle Condition="$(CheckCodingStyle) == ''">true</CheckCodingStyle>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="Exists('../../.git')">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" PrivateAssets="All" />
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="$(CheckCodingStyle) == true">

View File

@ -25,7 +25,7 @@ namespace Kyoo.Abstractions.Models
/// <summary>
/// A font of an <see cref="Episode"/>.
/// </summary>
public class Font
public class Font : ILink
{
/// <summary>
/// A human-readable identifier, used in the URL.
@ -47,6 +47,9 @@ namespace Kyoo.Abstractions.Models
/// </summary>
[SerializeIgnore] public string Path { get; set; }
/// <inheritdoc/>
public object Link { get; init; }
/// <summary>
/// Create a new empty <see cref="Font"/>.
/// </summary>
@ -56,12 +59,14 @@ namespace Kyoo.Abstractions.Models
/// Create a new <see cref="Font"/> from a path.
/// </summary>
/// <param name="path">The path of the font.</param>
public Font(string path)
/// <param name="episodeSlug">The slug of the episode that contains this font.</param>
public Font(string path, string episodeSlug)
{
Slug = Utility.ToSlug(PathIO.GetFileNameWithoutExtension(path));
Path = path;
File = PathIO.GetFileName(path);
Format = PathIO.GetExtension(path).Replace(".", string.Empty);
Link = $"/watch/{episodeSlug}/font/{Slug}.{Format}";
}
}
}

View File

@ -33,17 +33,17 @@ namespace Kyoo.Abstractions.Models
/// <summary>
/// The link of the current page.
/// </summary>
public Uri This { get; }
public string This { get; }
/// <summary>
/// The link of the first page.
/// </summary>
public Uri First { get; }
public string First { get; }
/// <summary>
/// The link of the next page.
/// </summary>
public Uri Next { get; }
public string Next { get; }
/// <summary>
/// The number of items in the current page.
@ -62,7 +62,7 @@ namespace Kyoo.Abstractions.Models
/// <param name="this">The link of the current page.</param>
/// <param name="next">The link of the next page.</param>
/// <param name="first">The link of the first page.</param>
public Page(ICollection<T> items, Uri @this, Uri next, Uri first)
public Page(ICollection<T> items, string @this, string next, string first)
{
Items = items;
This = @this;
@ -78,21 +78,21 @@ namespace Kyoo.Abstractions.Models
/// <param name="query">The list of query strings of the current page</param>
/// <param name="limit">The number of items requested for the current page.</param>
public Page(ICollection<T> items,
Uri url,
string url,
Dictionary<string, string> query,
int limit)
{
Items = items;
This = new Uri(url + query.ToQueryString());
This = url + query.ToQueryString();
if (items.Count == limit && limit > 0)
{
query["afterID"] = items.Last().ID.ToString();
Next = new Uri(url + query.ToQueryString());
Next = url + query.ToQueryString();
}
query.Remove("afterID");
First = new Uri(url + query.ToQueryString());
First = url + query.ToQueryString();
}
}
}

View File

@ -0,0 +1,31 @@
// Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo.
//
// See AUTHORS.md and LICENSE file in the project root for full license information.
//
// Kyoo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// Kyoo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Abstractions.Models
{
/// <summary>
/// An interface to represent resources that should have a link field in their return values (like videos).
/// </summary>
public interface ILink
{
/// <summary>
/// The link to return, in most cases this should be a string.
/// </summary>
public object Link { get; }
}
}

View File

@ -55,7 +55,7 @@ namespace Kyoo.Abstractions.Models
/// <summary>
/// A video, audio or subtitle track for an episode.
/// </summary>
public class Track : IResource
public class Track : IResource, ILink
{
/// <inheritdoc />
public int ID { get; set; }
@ -66,9 +66,9 @@ namespace Kyoo.Abstractions.Models
{
get
{
string type = Type.ToString().ToLower();
string type = Type.ToString().ToLowerInvariant();
string index = TrackIndex != 0 ? $"-{TrackIndex}" : string.Empty;
string episode = _episodeSlug ?? Episode?.Slug ?? EpisodeID.ToString();
string episode = _episodeSlug ?? Episode?.Slug ?? EpisodeID.ToString(CultureInfo.InvariantCulture);
return $"{episode}.{Language ?? "und"}{index}{(IsForced ? ".forced" : string.Empty)}.{type}";
}
@ -92,7 +92,7 @@ namespace Kyoo.Abstractions.Models
Language = match.Groups["lang"].Value;
if (Language == "und")
Language = null;
TrackIndex = match.Groups["index"].Success ? int.Parse(match.Groups["index"].Value) : 0;
TrackIndex = match.Groups["index"].Success ? int.Parse(match.Groups["index"].Value, CultureInfo.InvariantCulture) : 0;
IsForced = match.Groups["forced"].Success;
Type = Enum.Parse<StreamType>(match.Groups["type"].Value, true);
}
@ -198,6 +198,9 @@ namespace Kyoo.Abstractions.Models
/// </summary>
[SerializeIgnore] private Episode _episode;
/// <inheritdoc/>
public object Link => Type == StreamType.Subtitle ? $"/subtitle/{Slug}" : null;
// Converting mkv track language to c# system language tag.
private static string _GetLanguage(string mkvLanguage)
{

View File

@ -33,7 +33,7 @@ namespace Kyoo.Abstractions.Models
/// Information about tracks and display information that could be used by the player.
/// This contains mostly data from an <see cref="Episode"/> with another form.
/// </summary>
public class WatchItem : CustomTypeDescriptor, IThumbnails
public class WatchItem : CustomTypeDescriptor, IThumbnails, ILink
{
/// <summary>
/// The ID of the episode associated with this item.
@ -75,6 +75,11 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public string Title { get; set; }
/// <summary>
/// The summary of this episode.
/// </summary>
public string Overview { get; set; }
/// <summary>
/// The release date of this episode. It can be null if unknown.
/// </summary>
@ -126,11 +131,23 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public ICollection<Track> Subtitles { get; set; }
/// <summary>
/// The list of fonts that can be used to draw the subtitles.
/// </summary>
public ICollection<Font> Fonts { get; set; }
/// <summary>
/// The list of chapters. See <see cref="Chapter"/> for more information.
/// </summary>
public ICollection<Chapter> Chapters { get; set; }
/// <inheritdoc/>
public object Link => new
{
Direct = $"/video/direct/{Slug}",
Transmux = $"/video/transmux/{Slug}/master.m3u8",
};
/// <summary>
/// Create a <see cref="WatchItem"/> from an <see cref="Episode"/>.
/// </summary>
@ -138,8 +155,10 @@ namespace Kyoo.Abstractions.Models
/// <param name="library">
/// A library manager to retrieve the next and previous episode and load the show and tracks of the episode.
/// </param>
/// <param name="fs">A file system used to retrieve chapters informations.</param>
/// <param name="transcoder">The transcoder used to list fonts.</param>
/// <returns>A new WatchItem representing the given episode.</returns>
public static async Task<WatchItem> FromEpisode(Episode ep, ILibraryManager library)
public static async Task<WatchItem> FromEpisode(Episode ep, ILibraryManager library, IFileSystem fs, ITranscoder transcoder)
{
await library.Load(ep, x => x.Show);
await library.Load(ep, x => x.Tracks);
@ -197,6 +216,7 @@ namespace Kyoo.Abstractions.Models
EpisodeNumber = ep.EpisodeNumber,
AbsoluteNumber = ep.AbsoluteNumber,
Title = ep.Title,
Overview = ep.Overview,
ReleaseDate = ep.ReleaseDate,
Path = ep.Path,
Images = ep.Show.Images,
@ -204,36 +224,51 @@ namespace Kyoo.Abstractions.Models
Video = ep.Tracks.FirstOrDefault(x => x.Type == StreamType.Video),
Audios = ep.Tracks.Where(x => x.Type == StreamType.Audio).ToArray(),
Subtitles = ep.Tracks.Where(x => x.Type == StreamType.Subtitle).ToArray(),
Fonts = await transcoder.ListFonts(ep),
PreviousEpisode = previous,
NextEpisode = next,
Chapters = await _GetChapters(ep.Path)
Chapters = await _GetChapters(ep, fs),
IsMovie = ep.Show.IsMovie
};
}
// TODO move this method in a controller to support abstraction.
// TODO use a IFileManager to retrieve and read files.
private static async Task<ICollection<Chapter>> _GetChapters(string episodePath)
private static async Task<ICollection<Chapter>> _GetChapters(Episode episode, IFileSystem fs)
{
string path = PathIO.Combine(
PathIO.GetDirectoryName(episodePath)!,
string path = fs.Combine(
await fs.GetExtraDirectory(episode),
"Chapters",
PathIO.GetFileNameWithoutExtension(episodePath) + ".txt"
PathIO.GetFileNameWithoutExtension(episode.Path) + ".txt"
);
if (!File.Exists(path))
if (!await fs.Exists(path))
return Array.Empty<Chapter>();
try
{
return (await File.ReadAllLinesAsync(path))
using StreamReader sr = new(await fs.GetReader(path));
string chapters = await sr.ReadToEndAsync();
return chapters.Split('\n')
.Select(x =>
{
string[] values = x.Split(' ');
return new Chapter(float.Parse(values[0]), float.Parse(values[1]), string.Join(' ', values.Skip(2)));
if (
values.Length < 3
|| !float.TryParse(values[0], out float start)
|| !float.TryParse(values[1], out float end)
)
return null;
return new Chapter(
start,
end,
string.Join(' ', values.Skip(2))
);
})
.Where(x => x != null)
.ToArray();
}
catch
catch (Exception ex)
{
await Console.Error.WriteLineAsync($"Invalid chapter file at {path}");
Console.Error.WriteLine(ex.ToString());
return Array.Empty<Chapter>();
}
}

View File

@ -91,15 +91,5 @@ namespace Kyoo.Abstractions
{
return builder.RegisterRepository<T2>().As<T>();
}
/// <summary>
/// Get the public URL of kyoo using the given configuration instance.
/// </summary>
/// <param name="configuration">The configuration instance</param>
/// <returns>The public URl of kyoo (without a slash at the end)</returns>
public static Uri GetPublicUrl(this IConfiguration configuration)
{
return new Uri(configuration["basics:publicUrl"] ?? "http://localhost:5000");
}
}
}

Some files were not shown because too many files have changed in this diff Show More