wip: download single episode
This commit is contained in:
@@ -2,6 +2,9 @@ export default class DownloadOptionTr extends HTMLTableRowElement {
|
||||
H264_CODECS = ['h264', 'h.264', 'x264']
|
||||
H265_CODECS = ['h265', 'h.265', 'x265', 'hevc']
|
||||
|
||||
#downloadBtnEl;
|
||||
|
||||
url;
|
||||
size;
|
||||
quality;
|
||||
resolution;
|
||||
@@ -12,20 +15,31 @@ export default class DownloadOptionTr extends HTMLTableRowElement {
|
||||
mediaType;
|
||||
season;
|
||||
episode;
|
||||
filename;
|
||||
imdbId;
|
||||
episodeId;
|
||||
mediaTitle;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.url = this.getAttribute('url');
|
||||
this.size = this.getAttribute('size');
|
||||
this.quality = this.getAttribute('quality');
|
||||
this.resolution = this.getAttribute('resolution');
|
||||
this.codec = this.getAttribute('codec');
|
||||
this.seeders = this.getAttribute('seeders');
|
||||
this.provider = this.getAttribute('provider');
|
||||
this.filename = this.getAttribute('filename');
|
||||
this.imdbId = this.getAttribute('imdb-id');
|
||||
this.languages = JSON.parse(this.getAttribute('languages'));
|
||||
this.mediaType = this.getAttribute('media-type');
|
||||
this.mediaTitle = this.getAttribute('media-title');
|
||||
this.season = this.getAttribute('season') ?? null;
|
||||
this.episode = this.getAttribute('episode') ?? null;
|
||||
this.episodeId = this.getAttribute('episode-id') ?? null;
|
||||
|
||||
this.#downloadBtnEl = this.querySelector('.download-btn');
|
||||
this.#downloadBtnEl.addEventListener('click', () => this.download());
|
||||
// document.addEventListener('filterDownloadOptions', this.filter.bind(this));
|
||||
}
|
||||
connectedCallback() {
|
||||
@@ -90,4 +104,27 @@ export default class DownloadOptionTr extends HTMLTableRowElement {
|
||||
|
||||
return include;
|
||||
}
|
||||
|
||||
download() {
|
||||
console.log('Downloading dis bihh')
|
||||
fetch('/api/download', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url: this.url,
|
||||
title: this.mediaTitle,
|
||||
filename: this.filename,
|
||||
mediaType: this.mediaType,
|
||||
imdbId: this.imdbId,
|
||||
episodeId: this.episodeId
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
console.log(json)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ export default class EpisodeContainer extends HTMLElement {
|
||||
H265_CODECS = ['h265', 'h.265', 'x265', 'hevc']
|
||||
|
||||
options = [];
|
||||
showTitle;
|
||||
|
||||
#episodeSelectorEl;
|
||||
#resultsToggleBtnEl;
|
||||
@@ -12,6 +13,7 @@ export default class EpisodeContainer extends HTMLElement {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.showTitle = this.getAttribute('show-title');
|
||||
this.#resultsTableEl = this.querySelector('.results-container');
|
||||
this.#resultsToggleBtnEl = this.querySelector('.dropdown-button');
|
||||
this.#resultsCountBadgeEl = this.querySelector('.results-count-badge');
|
||||
|
||||
@@ -38,10 +38,6 @@ export default class extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
isSelected() {
|
||||
return this.episodeSelectorTarget.checked;
|
||||
}
|
||||
|
||||
download() {
|
||||
this.element.options.forEach(option => {
|
||||
const optionSelector = option.querySelector('input[type="checkbox"]');
|
||||
|
||||
Reference in New Issue
Block a user