ChandimaPrabath commited on
Commit
4b1ee51
·
1 Parent(s): 4e15391
Files changed (2) hide show
  1. app.py +0 -1
  2. templates/index.html +31 -25
app.py CHANGED
@@ -42,7 +42,6 @@ def authenticate_thetvdb():
42
  response = requests.post(auth_url, json=auth_data, proxies=proxies)
43
  response.raise_for_status()
44
  response_data = response.json()
45
- print("Auth Response Data:", response_data) # Debugging print statement
46
  THETVDB_TOKEN = response_data['data']['token']
47
  TOKEN_EXPIRY = datetime.now() + timedelta(days=30) # token is valid for 1 month
48
  except requests.RequestException as e:
 
42
  response = requests.post(auth_url, json=auth_data, proxies=proxies)
43
  response.raise_for_status()
44
  response_data = response.json()
 
45
  THETVDB_TOKEN = response_data['data']['token']
46
  TOKEN_EXPIRY = datetime.now() + timedelta(days=30) # token is valid for 1 month
47
  except requests.RequestException as e:
templates/index.html CHANGED
@@ -124,38 +124,44 @@
124
  card.className = 'card';
125
 
126
  const title = item.path.split('/').pop();
 
 
127
  const img = document.createElement('img');
128
- img.src = await fetchImage(title);
 
129
  card.appendChild(img);
130
 
131
  const titleElement = document.createElement('h3');
132
  titleElement.textContent = title;
133
  card.appendChild(titleElement);
 
134
  if (item.contents) {
135
- const p = document.createElement('p');
136
- p.textContent = `Contains ${item.contents.length} items`;
137
- card.appendChild(p);
138
- } else {
139
- const link = document.createElement('a');
140
- link.href = `/play/${encodeURIComponent(item.path)}`;
141
- link.textContent = 'Play';
142
- card.appendChild(link);
143
- }
144
 
145
- return card;
146
- }
147
 
148
- async function loadSection(endpoint, containerId) {
149
- const data = await fetchData(endpoint);
150
- const container = document.getElementById(containerId);
151
- container.innerHTML = ''; // Clear previous content
152
- for (const item of data) {
153
- container.appendChild(await createCard(item));
154
- }
155
- }
156
 
157
- document.addEventListener('DOMContentLoaded', () => {
158
- loadSection('/films', 'films-grid');
159
- loadSection('/tv', 'tv-grid');
160
- });
161
- </script>
 
 
 
124
  card.className = 'card';
125
 
126
  const title = item.path.split('/').pop();
127
+ const imgSrc = await fetchImage(title);
128
+
129
  const img = document.createElement('img');
130
+ img.src = imgSrc;
131
+ img.alt = title;
132
  card.appendChild(img);
133
 
134
  const titleElement = document.createElement('h3');
135
  titleElement.textContent = title;
136
  card.appendChild(titleElement);
137
+
138
  if (item.contents) {
139
+ const p = document.createElement('p');
140
+ p.textContent = `Contains ${item.contents.length} items`;
141
+ card.appendChild(p);
142
+ } else {
143
+ const link = document.createElement('a');
144
+ link.href = `/play/${encodeURIComponent(item.path)}`;
145
+ link.textContent = 'Play';
146
+ card.appendChild(link);
147
+ }
148
 
149
+ return card;
150
+ }
151
 
152
+ async function loadSection(endpoint, containerId) {
153
+ const data = await fetchData(endpoint);
154
+ const container = document.getElementById(containerId);
155
+ container.innerHTML = ''; // Clear previous content
156
+ for (const item of data) {
157
+ container.appendChild(await createCard(item));
158
+ }
159
+ }
160
 
161
+ document.addEventListener('DOMContentLoaded', () => {
162
+ loadSection('/films', 'films-grid');
163
+ loadSection('/tv', 'tv-grid');
164
+ });
165
+ </script>
166
+ </body>
167
+ </html>