mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #2044 from neilsb/schedules-direct-fix
Fix Schedules Direct Listings
This commit is contained in:
commit
93d3dd822a
1 changed files with 25 additions and 53 deletions
|
@ -83,63 +83,35 @@ export default function (page, providerId, options) {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sha256(str) {
|
|
||||||
if (!self.TextEncoder) {
|
|
||||||
return Promise.resolve('');
|
|
||||||
}
|
|
||||||
|
|
||||||
const buffer = new TextEncoder('utf-8').encode(str);
|
|
||||||
return crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
|
|
||||||
return hex(hash);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hex(buffer) {
|
|
||||||
const hexCodes = [];
|
|
||||||
const view = new DataView(buffer);
|
|
||||||
|
|
||||||
for (let i = 0; i < view.byteLength; i += 4) {
|
|
||||||
const value = view.getUint32(i);
|
|
||||||
const stringValue = value.toString(16);
|
|
||||||
const paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
|
|
||||||
hexCodes.push(paddedValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hexCodes.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitLoginForm() {
|
function submitLoginForm() {
|
||||||
loading.show();
|
loading.show();
|
||||||
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
|
const info = {
|
||||||
const info = {
|
Type: 'SchedulesDirect',
|
||||||
Type: 'SchedulesDirect',
|
Username: page.querySelector('.txtUser').value,
|
||||||
Username: page.querySelector('.txtUser').value,
|
EnableAllTuners: true,
|
||||||
EnableAllTuners: true,
|
Password: page.querySelector('.txtPass').value
|
||||||
Password: passwordHash,
|
};
|
||||||
Pw: page.querySelector('.txtPass').value
|
const id = providerId;
|
||||||
};
|
|
||||||
const id = providerId;
|
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
info.Id = id;
|
info.Id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
||||||
ValidateLogin: true
|
ValidateLogin: true
|
||||||
}),
|
}),
|
||||||
data: JSON.stringify(info),
|
data: JSON.stringify(info),
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
providerId = result.Id;
|
providerId = result.Id;
|
||||||
reload();
|
reload();
|
||||||
}, function () {
|
}, function () {
|
||||||
Dashboard.alert({ // ApiClient.ajax() error handler
|
Dashboard.alert({ // ApiClient.ajax() error handler
|
||||||
message: globalize.translate('ErrorSavingTvProvider')
|
message: globalize.translate('ErrorSavingTvProvider')
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue