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")
|
||||||
|
|
|
||||||
|
|
@ -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})));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue