ycdl/frontends/ycdl_flask/static/js/api.js

109 lines
2.9 KiB
JavaScript
Raw Normal View History

2020-06-03 19:54:20 +00:00
var api = {};
/**************************************************************************************************/
api.channels = {};
2020-06-03 20:00:44 +00:00
api.channels.add_channel =
function add_channel(channel_id, callback)
{
2020-09-03 22:44:58 +00:00
const url = "/add_channel";
const data = {"channel_id": channel_id};
2020-06-03 20:00:44 +00:00
return common.post(url, data, callback);
}
api.channels.delete_channel =
function delete_channel(channel_id, callback)
{
2020-09-03 22:44:58 +00:00
const url = `/channel/${channel_id}/delete`;
const data = {};
return common.post(url, data, callback);
}
api.channels.refresh_channel =
function refresh_channel(channel_id, force, callback)
{
2020-09-03 22:44:58 +00:00
const url = `/channel/${channel_id}/refresh`;
const data = {"force": force};
return common.post(url, data, callback);
}
api.channels.refresh_all_channels =
function refresh_all_channels(force, callback)
{
2020-09-03 22:44:58 +00:00
const url = "/refresh_all_channels";
const data = {"force": force};
return common.post(url, data, callback);
}
2020-06-03 20:01:28 +00:00
api.channels.set_automark =
function set_automark(channel_id, state, callback)
{
2020-09-03 22:44:58 +00:00
const url = `/channel/${channel_id}/set_automark`;
const data = {"state": state};
2020-06-03 20:01:28 +00:00
return common.post(url, data, callback);
}
api.channels.set_autorefresh =
function set_autorefresh(channel_id, autorefresh, callback)
{
const url = `/channel/${channel_id}/set_autorefresh`;
const data = {"autorefresh": autorefresh};
return common.post(url, data, callback);
}
2021-09-02 06:37:43 +00:00
api.channels.set_download_directory =
function set_download_directory(channel_id, download_directory, callback)
{
const url = `/channel/${channel_id}/set_download_directory`;
const data = {"download_directory": download_directory};
2021-09-02 06:37:43 +00:00
return common.post(url, data, callback);
}
api.channels.set_name =
function set_name(channel_id, name, callback)
{
const url = `/channel/${channel_id}/set_name`;
const data = {"name": name};
return common.post(url, data, callback);
}
api.channels.set_queuefile_extension =
function set_queuefile_extension(channel_id, extension, callback)
{
const url = `/channel/${channel_id}/set_queuefile_extension`;
const data = {"extension": extension};
return common.post(url, data, callback);
}
api.channels.callback_go_to_channels =
function callback_go_to_channels(response)
{
if (response.meta.status === 200)
{
window.location.href = "/channels";
}
else
{
alert(JSON.stringify(response));
}
}
2020-06-03 19:54:20 +00:00
/**************************************************************************************************/
api.videos = {};
api.videos.mark_state =
function mark_state(video_ids, state, callback)
{
2020-09-03 22:44:58 +00:00
const url = "/mark_video_state";
const data = {"video_ids": video_ids, "state": state};
return common.post(url, data, callback);
}
api.videos.start_download =
function start_download(video_ids, callback)
{
2020-09-03 22:44:58 +00:00
const url = "/start_download";
const data = {"video_ids": video_ids};
return common.post(url, data, callback);
}