mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Finishing the database creation of episodes and starting the creation of the web app.
This commit is contained in:
parent
9200c2b00e
commit
b821679fa8
@ -1,10 +1,8 @@
|
||||
<div class='container-fluid'>
|
||||
<div class='row'>
|
||||
<div class='col-sm-3'>
|
||||
<app-nav-menu></app-nav-menu>
|
||||
</div>
|
||||
<div class='col-sm-9 body-content'>
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="/docs/4.3/assets/brand/bootstrap-solid.svg" width="30" height="30" alt="">
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
|
@ -5,7 +5,6 @@ import { HttpClientModule } from '@angular/common/http';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { NavMenuComponent } from './nav-menu/nav-menu.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { CounterComponent } from './counter/counter.component';
|
||||
import { FetchDataComponent } from './fetch-data/fetch-data.component';
|
||||
@ -13,7 +12,6 @@ import { FetchDataComponent } from './fetch-data/fetch-data.component';
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
NavMenuComponent,
|
||||
HomeComponent,
|
||||
CounterComponent,
|
||||
FetchDataComponent
|
||||
|
@ -1,59 +0,0 @@
|
||||
li .glyphicon {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* Highlighting rules for nav menu items */
|
||||
li.link-active a,
|
||||
li.link-active a:hover,
|
||||
li.link-active a:focus {
|
||||
background-color: #4189C7;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Keep the nav menu independent of scrolling and on top of other items */
|
||||
.main-nav {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
/* On small screens, convert the nav menu to a vertical sidebar */
|
||||
.main-nav {
|
||||
height: 100%;
|
||||
width: calc(25% - 20px);
|
||||
}
|
||||
.navbar {
|
||||
border-radius: 0px;
|
||||
border-width: 0px;
|
||||
height: 100%;
|
||||
}
|
||||
.navbar-header {
|
||||
float: none;
|
||||
}
|
||||
.navbar-collapse {
|
||||
border-top: 1px solid #444;
|
||||
padding: 0px;
|
||||
}
|
||||
.navbar ul {
|
||||
float: none;
|
||||
}
|
||||
.navbar li {
|
||||
float: none;
|
||||
font-size: 15px;
|
||||
margin: 6px;
|
||||
}
|
||||
.navbar li a {
|
||||
padding: 10px 16px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.navbar a {
|
||||
/* If a menu item's text is too long, truncate it */
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<div class='main-nav'>
|
||||
<div class='navbar navbar-inverse'>
|
||||
<div class='navbar-header'>
|
||||
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse' [attr.aria-expanded]='isExpanded' (click)='toggle()'>
|
||||
<span class='sr-only'>Toggle navigation</span>
|
||||
<span class='icon-bar'></span>
|
||||
<span class='icon-bar'></span>
|
||||
<span class='icon-bar'></span>
|
||||
</button>
|
||||
<a class='navbar-brand' [routerLink]='["/"]'>Kyoo</a>
|
||||
</div>
|
||||
<div class='clearfix'></div>
|
||||
<div class='navbar-collapse collapse' [ngClass]='{ "in": isExpanded }'>
|
||||
<ul class='nav navbar-nav'>
|
||||
<li [routerLinkActive]='["link-active"]' [routerLinkActiveOptions]='{ exact: true }'>
|
||||
<a [routerLink]='["/"]' (click)='collapse()'>
|
||||
<span class='glyphicon glyphicon-home'></span> Home
|
||||
</a>
|
||||
</li>
|
||||
<li [routerLinkActive]='["link-active"]'>
|
||||
<a [routerLink]='["/counter"]' (click)='collapse()'>
|
||||
<span class='glyphicon glyphicon-education'></span> Counter
|
||||
</a>
|
||||
</li>
|
||||
<li [routerLinkActive]='["link-active"]'>
|
||||
<a [routerLink]='["/fetch-data"]' (click)='collapse()'>
|
||||
<span class='glyphicon glyphicon-th-list'></span> Fetch data
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,18 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-menu',
|
||||
templateUrl: './nav-menu.component.html',
|
||||
styleUrls: ['./nav-menu.component.css']
|
||||
})
|
||||
export class NavMenuComponent {
|
||||
isExpanded = false;
|
||||
|
||||
collapse() {
|
||||
this.isExpanded = false;
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
}
|
||||
}
|
@ -48,8 +48,6 @@ namespace Kyoo.InternalAPI
|
||||
{
|
||||
if(IsVideo(file) && !libraryManager.IsEpisodeRegistered(file))
|
||||
{
|
||||
Debug.WriteLine("&Should insert this: " + file);
|
||||
|
||||
string patern = config.GetValue<string>("regex");
|
||||
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
||||
Match match = regex.Match(file);
|
||||
@ -59,12 +57,9 @@ namespace Kyoo.InternalAPI
|
||||
bool seasonSuccess = long.TryParse(match.Groups["Season"].Value, out long seasonNumber);
|
||||
bool episodeSucess = long.TryParse(match.Groups["Episode"].Value, out long episodeNumber);
|
||||
|
||||
Debug.WriteLine("&ShowPath: " + showPath + " Show: " + showName + " season: " + seasonNumber + " episode: " + episodeNumber);
|
||||
|
||||
string showProviderIDs;
|
||||
if (!libraryManager.IsShowRegistered(showPath, out long showID))
|
||||
{
|
||||
Debug.WriteLine("&Should register show: " + showName);
|
||||
Show show = await metadataProvider.GetShowFromName(showName, showPath);
|
||||
showProviderIDs = show.ExternalIDs;
|
||||
showID = libraryManager.RegisterShow(show);
|
||||
@ -72,18 +67,13 @@ namespace Kyoo.InternalAPI
|
||||
else
|
||||
showProviderIDs = libraryManager.GetShowExternalIDs(showID);
|
||||
|
||||
Debug.WriteLine("&Show ID: " + showID);
|
||||
|
||||
if(!libraryManager.IsSeasonRegistered(showID, seasonNumber, out long seasonID))
|
||||
{
|
||||
Debug.WriteLine("&Should register season: " + showName + " - " + seasonNumber);
|
||||
Season season = await metadataProvider.GetSeason(showName, seasonNumber);
|
||||
season.ShowID = showID;
|
||||
showID = libraryManager.RegisterSeason(season);
|
||||
seasonID = libraryManager.RegisterSeason(season);
|
||||
}
|
||||
|
||||
Debug.WriteLine("&Season ID: " + seasonID);
|
||||
|
||||
Episode episode = await metadataProvider.GetEpisode(showProviderIDs, seasonNumber, episodeNumber);
|
||||
episode.ShowID = showID;
|
||||
episode.SeasonID = seasonID;
|
||||
|
@ -261,7 +261,6 @@ namespace Kyoo.InternalAPI
|
||||
public long RegisterShow(Show show)
|
||||
{
|
||||
string query = "INSERT INTO shows (slug, title, aliases, path, overview, genres, startYear, endYear, imgPrimary, imgThumb, imgLogo, imgBackdrop, externalIDs) VALUES($slug, $title, $aliases, $path, $overview, $genres, $startYear, $endYear, $imgPrimary, $imgThumb, $imgLogo, $imgBackdrop, $externalIDs);";
|
||||
Debug.WriteLine("&SQL QUERY:: " + query);
|
||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("slug", show.Slug);
|
||||
@ -288,7 +287,6 @@ namespace Kyoo.InternalAPI
|
||||
public long RegisterSeason(Season season)
|
||||
{
|
||||
string query = "INSERT INTO seasons (showID, seasonNumber, title, overview, year, imgPrimary, externalIDs) VALUES($showID, $seasonNumber, $title, $overview, $year, $imgPrimary, $externalIDs);";
|
||||
Debug.WriteLine("&SQL QUERY:: " + query);
|
||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("$showID", season.ShowID);
|
||||
@ -308,7 +306,6 @@ namespace Kyoo.InternalAPI
|
||||
public long RegisterEpisode(Episode episode)
|
||||
{
|
||||
string query = "INSERT INTO episodes (showID, seasonID, episodeNumber, title, overview, releaseDate, runtime, imgPrimary, externalIDs) VALUES($showID, $seasonID, $episodeNumber, $title, $overview, $releaseDate, $runtime, $imgPrimary, $externalIDs);";
|
||||
Debug.WriteLine("&SQL QUERY:: " + query);
|
||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("$showID", episode.ShowID);
|
||||
|
@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -122,7 +123,7 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
GetYear(data.firstAired),
|
||||
null, //endYear
|
||||
string.Format("{0}={1}|", Provider, data.id));
|
||||
return await GetShowByID(GetID(show.ExternalIDs)) ?? show;
|
||||
return (await GetShowByID(GetID(show.ExternalIDs))).Set(show.Slug, show.Path) ?? show;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -268,8 +269,6 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<Episode> GetEpisode(string externalIDs, long seasonNumber, long episodeNumber)
|
||||
{
|
||||
string id = GetID(externalIDs);
|
||||
@ -282,8 +281,8 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
if (token == null)
|
||||
return null;
|
||||
|
||||
long page = episodeNumber / 100 + 1;
|
||||
long index = episodeNumber % 100;
|
||||
int page = (int)episodeNumber / 100 + 1;
|
||||
int index = (int)episodeNumber % 100;
|
||||
|
||||
WebRequest request = WebRequest.Create("https://api.thetvdb.com/series/" + id + "/episodes?page=" + page);
|
||||
request.Method = "GET";
|
||||
@ -307,8 +306,8 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
dynamic data = JsonConvert.DeserializeObject(content);
|
||||
dynamic episode = data.data[index];
|
||||
|
||||
Debug.WriteLine("&Date: " + (string)episode.firstAired);
|
||||
return new Episode(episodeNumber, episode.episodeName, episode.overview, DateTime.Parse(episode.firstAired), -1, "https://www.thetvdb.com/banners/" + episode.filename, string.Format("TvDB={0}|", episode.id));
|
||||
DateTime dateTime = DateTime.ParseExact((string)episode.firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture);
|
||||
return new Episode(episodeNumber, (string)episode.episodeName, (string)episode.overview, dateTime, -1, "https://www.thetvdb.com/banners/" + episode.filename, string.Format("TvDB={0}|", episode.id));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -91,6 +91,13 @@ namespace Kyoo.Models
|
||||
reader["imgBackdrop"] as string,
|
||||
reader["externalIDs"] as string);
|
||||
}
|
||||
|
||||
public Show Set(string slug, string path)
|
||||
{
|
||||
Slug = slug;
|
||||
Path = path;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Status { Finished, Airing }
|
||||
|
Loading…
x
Reference in New Issue
Block a user