Documentation ¶
Overview ¶
Package uptoshare uploads files to one-click hosting sites.
Index ¶
- Constants
- Variables
- func FileNameFromURI(str string) string
- type FileType
- type Host
- type Links
- type Sender
- type Uploader
- func (up *Uploader) ListHistory() []Links
- func (up *Uploader) ListRemove(uri string) error
- func (up *Uploader) SetHistory(links []Links)
- func (up *Uploader) SetHistoryFile(file string)
- func (up *Uploader) SetHistorySize(nb int)
- func (up *Uploader) SetOnResult(call func(Links))
- func (up *Uploader) SetPostCheck(call func())
- func (up *Uploader) SetPreCheck(call func())
- func (up *Uploader) SiteFile(site string) error
- func (up *Uploader) SiteImage(site string) error
- func (up *Uploader) SiteText(site string) error
- func (up *Uploader) SiteVideo(site string) error
- func (up *Uploader) UploadGuess(data string)
- func (up *Uploader) Walk(call func(Links) bool)
Constants ¶
const HistoryFile = "uptoshare_history.txt"
HistoryFile defines the name of the default history file.
Variables ¶
var CodePadOrg = &Host{ Poster: upload.NewPostForm("http://codepad.org/", "code", "lang", "Plain Text", "submit", "Submit", ), Parse: func(h *Host, data string) Links { uri := h.GetURL("") ID := findLink(string(data), uri, "\"") if ID == "" { return linkWarn(h.Name() + ": parse failed") } return NewLinks(ID). Add("dl", ID+"/raw.txt"). Add("fork", ID+"/fork") }, }
CodePadOrg implements a Text Sender to the codepad.org website.
var FileBinCa = &Host{ Poster: upload.NewMultiparter("http://filebin.ca/upload.php", "file"), Parse: func(h *Host, data string) Links { ID := findPrefix(data, "url:", "\n") if ID == "" { return linkWarn(h.Name() + ": parse failed\n" + data) } return NewLinks(ID). Add("page", strings.Replace(ID, "http://ibin.co/", "http://filebin.ca/v/", 1)) }, }
FileBinCa implements a File Sender to the imagebin.ca website.
var FreemovTop = &Host{ Poster: upload.NewMultiparter("http://freemov.top/", "upload[]", "submit", "submit", ), Parse: func(h *Host, data string) Links { link := findPrefix(data, `id="name" value=`, ` />`) if link == "" { println(h.Name()+" -- ANSWER\n", data) return linkWarn(h.Name() + ": bad format") } return NewLinks("http://" + link) }, }
FreemovTop implements a File Sender to the freemov.top website.
var ImageBinCa = &Host{ Poster: upload.NewMultiparter("https://imagebin.ca/upload.php", "file", "private", "true", ), Parse: func(h *Host, data string) Links { ID := findPrefix(data, "url:", "\n") if ID == "" { return linkWarn(h.Name() + ": parse failed") } return NewLinks(ID). Add("page", strings.Replace(ID, "http://ibin.co/", "http://imagebin.ca/v/", 1)) }, }
ImageBinCa implements an Image Sender to the imagebin.ca website.
var ImageShackUs = &Host{ Poster: upload.NewMultiparter("http://imageshack.us/upload_api.php", "fileupload", "key", "ABDGHOQS7d32e206ee33ef8cefb208d55dd030a6", "public", "no", "xml", "yes", ), Parse: func(h *Host, data string) Links { return NewLinks(findPrefix(data, "<image_link>", "</image_link>")). Add("thumb", findPrefix(data, "<thumb_link>", "</thumb_link>")) }, }
ImageShackUs implements an Image Sender to the imageshack.us website.
var ImagebamCom = &Host{ Poster: upload.NewMultiparter("http://www.imagebam.com/sys/upload/save", "file[]", "content_type", "1", "thumb_size", "250", "thumb_aspect_ratio", "resize", "thumb_file_type", "jpg", ), Parse: func(h *Host, data string) Links { return NewLinks(findPrefix(data, "[URL=", "][IMG]")). Add("del", findLink(data, "http://www.imagebam.com/remove/", "'></div>")) }, }
ImagebamCom implements an Image Sender to the imagebam.com website.
var ImgclickNet = &Host{ Poster: upload.NewMultiparter("http://main.imgclick.net/cgi-bin/upload_file.cgi?upload_id=", "file_0", "upload_type", "file", ), Parse: func(h *Host, data string) Links { return NewLinks(findLink(data, "http://main.imgclick.net/i/", "[/IMG][/URL]")) }, }
ImgclickNet implements an Image Sender to the imgclick.net website.
var ImglandNet = &Host{ Poster: upload.NewMultiparter("https://imgland.net/process.php?subAPI=mainsite", "imagefile[]", "usubmit", "true", ), Parse: func(h *Host, data string) Links { ret := &imglandNetJSON{} e := json.Unmarshal([]byte(data), ret) if e != nil { return linkErr(e, h.Name()) } return NewLinks(ret.URL) }, }
ImglandNet implements an Image Sender to the imagebam.com website.
var ImgurCom = &Host{ Poster: upload.NewMultiparter("http://imgur.com/api/upload.xml", "image", "key", "b3625162d3418ac51a9ee805b1840452", ), Parse: func(h *Host, data string) Links { println(data) return NewLinks(findPrefix(data, "<original_image>", "</original_image>")). Add("thumb", findPrefix(data, "<small_thumbnail>", "</small_thumbnail>")). Add("large", findPrefix(data, "<large_thumbnail>", "</large_thumbnail>")). Add("page", findPrefix(data, "<imgur_page>", "</imgur_page>")). Add("del", findPrefix(data, "<delete_page>", "</delete_page>")) }, }
ImgurCom implements an Image Sender to the imgur.com website.
var LeopardHosting = &Host{ Poster: upload.NewMultiparter("http://leopard.hosting/upload.php", "uploadContent", "public", "no", "showname", "no", "json", "true", ), Parse: func(h *Host, data string) Links { ret := &leopardHostingJSON{} e := json.Unmarshal([]byte(data), ret) if e != nil { return linkErr(e, h.Name()) } return NewLinks(ret.Upload.DownloadURL). Add("del", ret.Upload.DeleteURL). Add("support", ret.Upload.Support). Add("ID", ret.Upload.FileCode) }, }
LeopardHosting implements a File Sender to the leopard.hosting website.
var PasteBinCom = &Host{ Poster: &upload.AsPostFormHTTP{ UpBase: upload.NewBaseURL("http://pastebin.com/api/api_post.php"), ContentRef: "api_paste_code", Options: map[string]string{ "api_option": "paste", "api_paste_private": "1", "api_paste_expire_date": "1M", "api_paste_format": "text", "api_dev_key": "4dacb211338b25bfad20bc6d4358e555", }, PrePost: func(hp *upload.AsPostFormHTTP, content *string) error { hp.Options["api_user_key"] = "" return nil }, }, Parse: func(h *Host, data string) Links { if !strings.HasPrefix(data, "http://") { return linkWarn(h.Name() + ": bad format: " + data) } return NewLinks(data) }, }
PasteBinCom implements a Text Sender to the pastebin.com website.
var PasteBinMozillaOrg = &Host{ Poster: &upload.AsPostFormHTTP{ UpBase: upload.NewBaseURL("https://pastebin.mozilla.org"), ContentRef: "code2", Options: map[string]string{ "format": "text", "paste": "Send", "expiry": "d", "remember": "0", "parent_pid": "", }, PrePost: func(hp *upload.AsPostFormHTTP, content *string) error { hp.Options["poster"] = "Anonymous" return nil }, }, Parse: func(h *Host, data string) Links { ID := findLink(data, "/?dl=", `"`) if ID == "" { return linkWarn(h.Name() + ": parse failed\n" + data) } uri := h.GetURL("") return NewLinks(uri+ID). Add("dl", uri+"/"+ID[5:]) }, }
PasteBinMozillaOrg implements a Text Sender to the pastebin.mozilla.org website.
var PasteUbuntuCom = &Host{ Poster: &upload.AsPostFormHTTP{ UpBase: upload.NewBaseURL("http://paste.ubuntu.com"), ContentRef: "content", Options: map[string]string{ "syntax": "text", "submit": "Paste!", }, PrePost: func(hp *upload.AsPostFormHTTP, content *string) error { hp.Options["poster"] = "Anonymous" return nil }, }, Parse: func(h *Host, data string) Links { ID := findPrefix(data, `class="pturl" href="/`, "/plain/") if ID == "" { return linkWarn(h.Name() + ": parse failed\n" + data) } return NewLinks(h.GetURL("") + "/" + ID) }, }
PasteUbuntuCom implements a Text Sender to the paste.ubuntu.com website.
var PixeldraIn = &Host{ Poster: &upload.AsMultipart{ UpBase: upload.NewBaseURL("http://pixeldra.in/api/upload"), FileRef: "file", PrePost: func(m *upload.AsMultipart, file string) error { m.Options = map[string]string{ "fileName": filepath.Base(file), } return nil }, }, Parse: func(h *Host, data string) Links { ret := pixeldraInJSON{} e := json.Unmarshal([]byte(data), &ret) if e != nil { return linkErr(e, h.Name()) } return NewLinks(ret.URL). Add("del", ret.ID) }, }
PixeldraIn implements a File Sender to the pixeldra.in website.
var PlayGolangOrg = &Host{ Poster: upload.NewRequester("POST", "https://play.golang.org/share"), Parse: func(h *Host, data string) Links { return NewLinks("https://play.golang.org/p/" + data) }, }
PlayGolangOrg implements a Text Sender to the play.golang.org website.
var PostimageOrg = &Host{ Poster: upload.NewMultiparter("https://old.postimage.org/", "upload[]", "adult", "no", ), Parse: func(h *Host, data string) Links { return NewLinks(findLink(data, "http://postimg.org/image/", "' ")). Add("thumb", findPrefix(data, "[img]", "[/img]")). Add("del", findLink(data, "http://postimg.org/delete/", "<")) }, }
PostimageOrg implements an Image Sender to the postimage.org website.
var TransferSh = &Host{ Poster: &upload.AsRequestHTTP{ Method: "PUT", UpBase: upload.NewBaseCB(func(file string) string { return "https://transfer.sh/" + filepath.Base(file) }), }, Parse: func(h *Host, data string) Links { data = strings.Trim(data, " \n") if data == "Not Found" { return linkWarn(h.Name() + " has answered: " + data) } return NewLinks(data) }, }
TransferSh implements a File Sender to the transfer.sh website.
var VideoBinOrg = &Host{ Poster: upload.NewMultiparter("https://videobin.org/add", "videoFile", "api", "1", ), Parse: func(h *Host, data string) Links { return NewLinks(data) }, }
VideoBinOrg implements a Video Sender to the postimage.org website.
Functions ¶
func FileNameFromURI ¶
FileNameFromURI strips file:// in front of a file path.
TODO: check nothing is missing from the original call : g_filename_from_uri
Types ¶
type FileType ¶
type FileType int
FileType defines the type of a backend.
File and backends types supported.
type Links ¶
Links contains the result data of an upload.
type Sender ¶
type Sender interface { SetName(string) SetConfig(*upload.Config) Send(r io.Reader, size int64, filename string) Links }
Sender defines the common backend upload interface.
type Uploader ¶
type Uploader struct { LimitRate int PostAnonymous bool FileForAll bool // Log provides a common logger for the uptoshare service. Log cdtype.Logger // contains filtered or unexported fields }
Uploader manages an upload queue to send files to one-click hosting websites.
func (*Uploader) ListHistory ¶
ListHistory returns the history content.
func (*Uploader) ListRemove ¶
ListRemove removes an item from the history..
func (*Uploader) SetHistory ¶
SetHistory sets the new history content.
func (*Uploader) SetHistoryFile ¶
SetHistoryFile sets the location of the history file.
func (*Uploader) SetHistorySize ¶
SetHistorySize sets the size of the history.
func (*Uploader) SetOnResult ¶
SetOnResult sets the result return method.
func (*Uploader) SetPostCheck ¶
func (up *Uploader) SetPostCheck(call func())
SetPostCheck sets the post-upload action.
func (*Uploader) SetPreCheck ¶
func (up *Uploader) SetPreCheck(call func())
SetPreCheck sets the pre-upload action.
func (*Uploader) UploadGuess ¶
UploadGuess data to the configured server for file type.