This repository has been archived on 2024-01-17. You can view files and clone it, but cannot push or open issues or pull requests.
dlbot4/instagram/main.go
Nulo 892af35ea3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
usar cobalt para tiktok + subir imagenes con audio
2023-12-28 23:11:52 -03:00

39 lines
795 B
Go

package instagram
import (
"log"
"net/http"
"net/url"
"strings"
"nulo.in/dlbot/common"
)
type Instagram struct {
http.Client
}
var Responder *Instagram = &Instagram{}
func (r *Instagram) Respond(url *url.URL) (*common.Uploadable, common.Error) {
if url.Hostname() != "instagram.com" && url.Hostname() != "www.instagram.com" {
return nil, common.NotValid
}
if strings.Index(url.Path, "/reel/") != 0 && strings.Index(url.Path, "/p/") != 0 {
return nil, common.NotValid
}
lookup, err := r.lookup(url.String())
if err != nil {
log.Println(err)
if strings.Index(url.Path, "/p/") == 0 {
return nil, common.NotValid
}
return nil, common.HadError
}
return &common.Uploadable{
VideoUrl: lookup.VideoUrl,
Caption: "instagram.com/" + lookup.Author,
}, common.OK
}