Skip to content

Commit

Permalink
Cria catálogo de videos agruapdos por palavras chave
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielaTiago committed Dec 9, 2023
1 parent 95d4806 commit 5efa59c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/app/pages/video/video.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { VideoService } from '../../services/video.service';
import { IVideo } from 'src/shared/model/video.model';
import { UNB_TV_CHANNEL_ID } from 'src/app/app.constant';
import { VideosCatalog } from 'src/shared/model/catalog.model';

@Component({
selector: 'app-video',
Expand All @@ -12,6 +13,7 @@ export class VideoComponent implements OnInit {
unbTvChannelId = UNB_TV_CHANNEL_ID;
videosEduplay: IVideo[] = [];
unbTvVideos: IVideo[] = [];
catalog: VideosCatalog = new VideosCatalog();

constructor(private videoService: VideoService) {}

Expand All @@ -29,6 +31,7 @@ export class VideoComponent implements OnInit {
},
complete: () => {
this.filterVideosByChannel(this.videosEduplay);
this.videosCatalog(this.unbTvVideos);
},
});
}
Expand All @@ -41,4 +44,56 @@ export class VideoComponent implements OnInit {
if (channel[0].id === this.unbTvChannelId) this.unbTvVideos.push(video);
});
}

videosCatalog(videos: IVideo[]): void {
videos.forEach((video) => {
let keywords = video.keywords;
if (keywords) {
keywords = keywords.toLowerCase();
if (keywords.includes('arte') || keywords.includes('cultura')) {
this.catalog.artAndCulture?.push(video);
return;
} else if (keywords.includes('entrevista')) {
this.catalog.interviews?.push(video);
return;
} else if (keywords.includes('cinema')) {
this.catalog.cinema?.push(video);
return;
} else if (
keywords.includes('documentais') ||
keywords.includes('documentarios')
) {
this.catalog.documentaries.push(video);
return;
} else if (
keywords.includes('pesquisa') ||
keywords.includes('ciência') ||
keywords.includes('ciências')
) {
this.catalog.researchAndScience?.push(video);
} else if (keywords.includes('jornalismo')) {
this.catalog.journalism.push(video);
return;
} else if (
keywords.includes('culinária') ||
keywords.includes('variedades')
) {
this.catalog.cookingAndVarieties.push(video);
return;
} else if (
keywords.includes('séries especiais') ||
keywords.includes('eleições') ||
keywords.includes('floresta de gente') ||
keywords.includes('guia do calouro') ||
keywords.includes('memórias') ||
keywords.includes('arquitetura')
) {
this.catalog.specialSeries.push(video);
return;
} else {
this.catalog.unbtv.push(video);
}
}
});
}
}
13 changes: 13 additions & 0 deletions src/shared/model/catalog.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { IVideo } from './video.model';

export class VideosCatalog {
journalism: IVideo[] = [];
artAndCulture: IVideo[] = [];
interviews: IVideo[] = [];
cinema: IVideo[] = [];
documentaries: IVideo[] = [];
researchAndScience: IVideo[] = [];
specialSeries: IVideo[] = [];
unbtv: IVideo[] = [];
cookingAndVarieties: IVideo[] = [];
}

0 comments on commit 5efa59c

Please sign in to comment.