mirror of https://github.com/PiyushXCoder/lupt.git
Migrated to new Tenor API
This commit is contained in:
parent
b92a889e3a
commit
ab3a31426d
17
src/main.rs
17
src/main.rs
|
|
@ -156,15 +156,24 @@ async fn gif(req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
let tenor_key = TENOR_API_KEY.read().unwrap();
|
let tenor_key = TENOR_API_KEY.read().unwrap();
|
||||||
let key = match &*tenor_key {
|
let key = match &*tenor_key {
|
||||||
Some(a) => a.as_str(),
|
Some(a) => a.as_str(),
|
||||||
None => "",
|
None => panic!("No api key!"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let url = format!(
|
let url = if name != "" {
|
||||||
"https://g.tenor.com/v1/search?q={}&key={}&limit=20&media_filter=tinygif&pos={}",
|
format!(
|
||||||
|
"https://tenor.googleapis.com/v2/search?q={}&key={}&limit=20&media_filter=tinygif&pos={}",
|
||||||
name.replace(" ", "+"),
|
name.replace(" ", "+"),
|
||||||
key,
|
key,
|
||||||
pos
|
pos
|
||||||
);
|
)
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"https://tenor.googleapis.com/v2/featured?key={}&limit=20&media_filter=tinygif&pos={}",
|
||||||
|
key,
|
||||||
|
pos
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.get(url)
|
.get(url)
|
||||||
.header("User-Agent", "actix-web/3.0")
|
.header("User-Agent", "actix-web/3.0")
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ if(!('WebSocket' in window || 'MozWebSocket' in window)) {
|
||||||
socket.onopen = function(event) {
|
socket.onopen = function(event) {
|
||||||
var params = window.location.search;
|
var params = window.location.search;
|
||||||
params = params.substr(1,params.length).split('&');
|
params = params.substr(1,params.length).split('&');
|
||||||
|
|
||||||
if(params.length < 3) {
|
if(params.length < 3) {
|
||||||
State.hideProgress();
|
State.hideProgress();
|
||||||
return;
|
return;
|
||||||
|
|
@ -187,7 +187,7 @@ function connect_next() {
|
||||||
socket.send(JSON.stringify({ cmd: 'randnext' }));
|
socket.send(JSON.stringify({ cmd: 'randnext' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
function leave() {
|
function leave() {
|
||||||
if(actions.has_key('leave')) return;
|
if(actions.has_key('leave')) return;
|
||||||
actions.clear();
|
actions.clear();
|
||||||
actions.add('leave', function() {
|
actions.add('leave', function() {
|
||||||
|
|
@ -294,14 +294,14 @@ function refreshVayaktiList() {
|
||||||
.append($('<td>').append(key)));
|
.append($('<td>').append(key)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function autosize(el){
|
function autosize(el){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
el.style.cssText = 'height:auto; padding:0';
|
el.style.cssText = 'height:auto; padding:0';
|
||||||
el.style.cssText = 'height:' + el.scrollHeight + 'px';
|
el.style.cssText = 'height:' + el.scrollHeight + 'px';
|
||||||
$('#reply_clip').css('bottom', (el.scrollHeight + 20) + 'px');
|
$('#reply_clip').css('bottom', (el.scrollHeight + 20) + 'px');
|
||||||
$('#selected_clip').css('bottom', (el.scrollHeight + 30) + 'px');
|
$('#selected_clip').css('bottom', (el.scrollHeight + 30) + 'px');
|
||||||
},0);
|
},0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dialog
|
// Dialog
|
||||||
|
|
@ -311,7 +311,7 @@ function dialog(prop, call) {
|
||||||
$('#dialog_title').text(prop.title);
|
$('#dialog_title').text(prop.title);
|
||||||
$('#dialog_text').text(prop.text);
|
$('#dialog_text').text(prop.text);
|
||||||
$('#dialog_check_label').text(prop.checkLabel);
|
$('#dialog_check_label').text(prop.checkLabel);
|
||||||
|
|
||||||
if(prop.check) $('#dialog_checkbox').removeClass('is-hidden');
|
if(prop.check) $('#dialog_checkbox').removeClass('is-hidden');
|
||||||
else $('#dialog_checkbox').addClass('is-hidden');
|
else $('#dialog_checkbox').addClass('is-hidden');
|
||||||
|
|
||||||
|
|
@ -347,7 +347,7 @@ function loadGif() {
|
||||||
area.find('[name=more]').remove();
|
area.find('[name=more]').remove();
|
||||||
positiongif = data.next;
|
positiongif = data.next;
|
||||||
data.results.forEach(function(result) {
|
data.results.forEach(function(result) {
|
||||||
var gif = result.media[0].tinygif.url;
|
var gif = result.media_formats.tinygif.url;
|
||||||
area.append($('<button>', {class: 'button', onclick: 'sendGif("'+encodeURI(gif)+'"); $("#gif_clip").addClass("is-hidden");'})
|
area.append($('<button>', {class: 'button', onclick: 'sendGif("'+encodeURI(gif)+'"); $("#gif_clip").addClass("is-hidden");'})
|
||||||
.append($('<img>', {src: gif})));
|
.append($('<img>', {src: gif})));
|
||||||
});
|
});
|
||||||
|
|
@ -361,4 +361,4 @@ function sendGif(gif) {
|
||||||
cmd: "img",
|
cmd: "img",
|
||||||
src: gif
|
src: gif
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue