JAYNESTV commited on
Commit
4fd5da5
·
verified ·
1 Parent(s): 7d96fba

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +71 -8
index.html CHANGED
@@ -3047,13 +3047,10 @@ function renderTranslatedDetail(d) {
3047
  };
3048
  document.getElementById('trDownloadBtn').onclick = () => {
3049
  const url = currentUrl();
 
 
3050
  if (!url) { showToast('Hakuna link ya kupakua bado.'); return; }
3051
- let label = '';
3052
- if (d.isSeries) {
3053
- const chip = document.querySelector('#trEpisodeRow .tab-chip.active');
3054
- label = [d.selectedSeason, chip ? chip.dataset.ep : ''].filter(Boolean).join(' ');
3055
- }
3056
- queueTranslatedDownload(d, url, label);
3057
  };
3058
  document.getElementById('trShareBtn').onclick = () => shareTranslatedTitle(d);
3059
 
@@ -6609,6 +6606,63 @@ function renderDownloadsScreenIfActive(){
6609
  updateDownloadsBadge();
6610
  }
6611
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6612
  // Zilizotafsiriwa -> foleni ya Downloads (mux-movie + speed/ukubwa + kucheza ndani ya app)
6613
  function queueTranslatedDownload(d, url, epLabel){
6614
  if (!url) return;
@@ -6989,13 +7043,13 @@ function updateDlSelectAllUI(){
6989
  const label = document.getElementById('dlSelectAllLabel');
6990
  const allOn = dlItemsCache.length > 0 && dlSelection.size === dlItemsCache.length;
6991
  check.classList.toggle('checked', allOn);
6992
- label.textContent = t('dl_select_all') + ` (${dlItemsCache.length} ${dlMode === 'episodes' ? t('dl_episodes') : t('dl_resolutions')})`;
6993
  }
6994
 
6995
  function updateDlConfirmUI(){
6996
  const btn = document.getElementById('dlConfirmBtn');
6997
  btn.disabled = dlSelection.size === 0;
6998
- btn.innerHTML = ICON_DOWNLOAD + ' ' + esc(t('dl_select') + ' ' + (dlMode === 'episodes' ? t('dl_episodes') : t('dl_resolutions')));
6999
  }
7000
 
7001
  document.getElementById('dlSelectAllRow').onclick = () => {
@@ -7231,6 +7285,15 @@ async function realDlConfirmHandler() {
7231
  }
7232
 
7233
  items.forEach(it => {
 
 
 
 
 
 
 
 
 
7234
  dlQueueItems.push({
7235
  id: dlIdSeq++,
7236
  title: dlMode === 'episodes' ? `${dlSubjectRef.title} — S${it.se}E${it.ep}` : `${dlSubjectRef.title} (${it.resolution}p)`,
 
3047
  };
3048
  document.getElementById('trDownloadBtn').onclick = () => {
3049
  const url = currentUrl();
3050
+ // Series: tafuta episode ZOTE (season zote) na uonyeshe orodha ya kuchagua / Select All.
3051
+ if (d.isSeries) { openTranslatedDownloadSheet(d); return; }
3052
  if (!url) { showToast('Hakuna link ya kupakua bado.'); return; }
3053
+ queueTranslatedDownload(d, url, '');
 
 
 
 
 
3054
  };
3055
  document.getElementById('trShareBtn').onclick = () => shareTranslatedTitle(d);
3056
 
 
6606
  updateDownloadsBadge();
6607
  }
6608
 
6609
+ // Zilizotafsiriwa (series) -> tafuta episode ZOTE za season zote, mtumiaji achague (au Select All)
6610
+ async function openTranslatedDownloadSheet(d){
6611
+ document.getElementById('dlConfirmBtn').onclick = realDlConfirmHandler;
6612
+ dlMode = 'translated';
6613
+ dlSubjectRef = { id: d.id, title: d.title, poster: d.poster || null, dj: d.dj || '' };
6614
+ dlSelection = new Set();
6615
+ dlItemsCache = [];
6616
+ const sheet = document.getElementById('dlSheet');
6617
+ const titleEl = document.getElementById('dlSheetTitle');
6618
+ const badgeEl = document.getElementById('dlSheetBadge');
6619
+ const listEl = document.getElementById('dlList');
6620
+ const selectAllRow = document.getElementById('dlSelectAllRow');
6621
+ document.getElementById('dlProgress').style.display = 'none';
6622
+ listEl.style.display = ''; selectAllRow.style.display = '';
6623
+ document.getElementById('dlConfirmBtn').style.display = '';
6624
+ titleEl.textContent = 'Download Episodes';
6625
+ badgeEl.textContent = '';
6626
+ listEl.innerHTML = '<div class="dl-progress">' + esc(t('dl_searching_eps')) + '</div>';
6627
+ sheet.classList.add('on');
6628
+ try {
6629
+ // Pata orodha kamili ya sasa kutoka server (ikishindwa, tumia tuliyonayo tayari)
6630
+ let vids = d.vids || {};
6631
+ try {
6632
+ const r = await fetch(TRANSLATED_BASE + '?id=' + encodeURIComponent(d.id), { headers: { apikey: TRANSLATED_KEY } });
6633
+ const j = await r.json();
6634
+ const fresh = j && j.movie && j.movie.video_urls;
6635
+ if (fresh && Object.keys(fresh).length) vids = fresh;
6636
+ } catch (_) {}
6637
+ const nat = (a, b) => String(a).localeCompare(String(b), undefined, { numeric: true });
6638
+ const seasons = Object.keys(vids).filter(k => vids[k] && typeof vids[k] === 'object').sort(nat);
6639
+ const multi = seasons.length > 1;
6640
+ const items = [];
6641
+ seasons.forEach(sn => {
6642
+ Object.keys(vids[sn]).sort(nat).forEach(ek => {
6643
+ const url = vids[sn][ek];
6644
+ if (!url || typeof url !== 'string') return;
6645
+ const num = String(ek).match(/\d+/);
6646
+ items.push({
6647
+ key: 'tr:' + sn + '|' + ek, se: sn, ep: ek, streamUrl: url,
6648
+ title: multi ? sn + ' \u00b7 ' + ek : ek,
6649
+ sub: d.dj ? 'DJ ' + d.dj : d.title,
6650
+ qtitle: d.title + ' \u2014 ' + (multi ? sn + ' ' : '') + ek,
6651
+ poster: d.poster || null,
6652
+ thumbLabel: num ? 'EP ' + num[0] : String(ek).slice(0, 4),
6653
+ });
6654
+ });
6655
+ });
6656
+ if (!items.length) throw new Error(t('dl_err_no_eps'));
6657
+ badgeEl.textContent = items.length + ' EP';
6658
+ dlItemsCache = items;
6659
+ renderDlList();
6660
+ } catch (e) {
6661
+ listEl.innerHTML = `<div class="dl-progress">${esc(e.message || 'Imeshindwa kupata vipindi.')}</div>`;
6662
+ selectAllRow.style.display = 'none';
6663
+ }
6664
+ }
6665
+
6666
  // Zilizotafsiriwa -> foleni ya Downloads (mux-movie + speed/ukubwa + kucheza ndani ya app)
6667
  function queueTranslatedDownload(d, url, epLabel){
6668
  if (!url) return;
 
7043
  const label = document.getElementById('dlSelectAllLabel');
7044
  const allOn = dlItemsCache.length > 0 && dlSelection.size === dlItemsCache.length;
7045
  check.classList.toggle('checked', allOn);
7046
+ label.textContent = t('dl_select_all') + ` (${dlItemsCache.length} ${(dlMode === 'episodes' || dlMode === 'translated') ? t('dl_episodes') : t('dl_resolutions')})`;
7047
  }
7048
 
7049
  function updateDlConfirmUI(){
7050
  const btn = document.getElementById('dlConfirmBtn');
7051
  btn.disabled = dlSelection.size === 0;
7052
+ btn.innerHTML = ICON_DOWNLOAD + ' ' + esc(t('dl_select') + ' ' + ((dlMode === 'episodes' || dlMode === 'translated') ? t('dl_episodes') : t('dl_resolutions')));
7053
  }
7054
 
7055
  document.getElementById('dlSelectAllRow').onclick = () => {
 
7285
  }
7286
 
7287
  items.forEach(it => {
7288
+ if (dlMode === 'translated') {
7289
+ if (dlQueueItems.some(q => q.mode === 'translated' && q.streamUrl === it.streamUrl && q.status !== 'error')) return; // tayari ipo
7290
+ dlQueueItems.push({
7291
+ id: dlIdSeq++, title: it.qtitle, sub: it.sub || '', poster: it.poster || null, thumbLabel: it.thumbLabel || '',
7292
+ status: 'waiting', progressText: '', mode: 'translated',
7293
+ subjectId: 'tr:' + dlSubjectRef.id, subjectTitle: it.qtitle, streamUrl: it.streamUrl, sizeBytes: null,
7294
+ });
7295
+ return;
7296
+ }
7297
  dlQueueItems.push({
7298
  id: dlIdSeq++,
7299
  title: dlMode === 'episodes' ? `${dlSubjectRef.title} — S${it.se}E${it.ep}` : `${dlSubjectRef.title} (${it.resolution}p)`,