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 key = match &*tenor_key {
|
||||
Some(a) => a.as_str(),
|
||||
None => "",
|
||||
None => panic!("No api key!"),
|
||||
};
|
||||
|
||||
let url = format!(
|
||||
"https://g.tenor.com/v1/search?q={}&key={}&limit=20&media_filter=tinygif&pos={}",
|
||||
let url = if name != "" {
|
||||
format!(
|
||||
"https://tenor.googleapis.com/v2/search?q={}&key={}&limit=20&media_filter=tinygif&pos={}",
|
||||
name.replace(" ", "+"),
|
||||
key,
|
||||
pos
|
||||
);
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"https://tenor.googleapis.com/v2/featured?key={}&limit=20&media_filter=tinygif&pos={}",
|
||||
key,
|
||||
pos
|
||||
)
|
||||
};
|
||||
|
||||
let response = client
|
||||
.get(url)
|
||||
.header("User-Agent", "actix-web/3.0")
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ function loadGif() {
|
|||
area.find('[name=more]').remove();
|
||||
positiongif = data.next;
|
||||
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");'})
|
||||
.append($('<img>', {src: gif})));
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue