hydrusapi

package module
v0.0.0-...-ec65f35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package hydrusapi implements the v11 hydrus api(https://hydrusnetwork.github.io/hydrus/help/client) in golang

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIVersion

type APIVersion struct {
	Version int `json:"version"`
}

APIVersion number of hydrus client api

type AddFile

type AddFile struct {
	Status int    `json:"status"`
	Hash   string `json:"hash"`
	Note   string `json:"note"`
}

AddFile info about added file

type AddFileParams

type AddFileParams struct {
	Path string `json:"path"`
}

AddFileParams is a struct for params for adding a file

type AddTags

type AddTags interface{}

AddTags is return status

type AddTagsParams

type AddTagsParams struct {
	Hash                        []string    `json:"hash"`                                       //sha256 hash
	ServiceNamesToActionsToTags interface{} `json:"service_names_to_actions_to_tags,omitempty"` //map[string][]string
	ServiceNamesToTags          interface{} `json:"service_names_to_tags,omitempty"`            //map[string][]string
}

AddTagsParams params needed to add tags to files 0 - Add to a local tag service. 1 - Delete from a local tag service. 2 - Pend to a tag repository. 3 - Rescind a pend from a tag repository. 4 - Petition from a tag repository. (This is special) 5 - Rescind a petition from a tag repository.

{
	"hash" : "df2a7b286d21329fc496e3aa8b8a08b67bb1747ca32749acb3f5d544cbfc0f56",
	"service_names_to_actions_to_tags" : {
		"my tags" : {
			"0" : [ "character:supergirl", "rating:safe" ],
			"1" : [ "character:superman" ]
		},
		"public tag repository" : {
			"2" : [ "character:supergirl", "rating:safe" ],
			"3" : [ "filename:image.jpg" ],
			"4" : [ [ "creator:danban faga", "typo" ], [ "character:super_girl", "underscore" ] ]
			"5" : [ "skirt" ]
		}
	}
}
{
	"hashes" : [ "df2a7b286d21329fc496e3aa8b8a08b67bb1747ca32749acb3f5d544cbfc0f56", "f2b022214e711e9a11e2fcec71bfd524f10f0be40c250737a7861a5ddd3faebf" ],
	"service_names_to_tags" : {
		"my tags" : [ "process this" ],
		"public tag repository" : [ "creator:dandon fuga" ]
	}
}

type AddURL

type AddURL struct {
	HumanResultText string `json:"human_result_text"`
	NormalizedURL   string `json:"normalized_url"`
}

AddURL is a struct

type AddURLParams

type AddURLParams struct {
	URL                 string      `json:"url"`
	DestinationPageName string      `json:"destination_page_name"`
	ShowDestinationPage bool        `json:"show_destination_page"`
	ServiceNamesToTags  interface{} `json:"service_names_to_tags"`
}
AddURLParams is a struct for params for adding a url
{
	"url" : "https://8ch.net/tv/res/1846574.html",
	"destination_page_name" : "kino zone",
	"service_names_to_tags" : {
		"local tags" : [ "as seen on /tv/" ]
	}
}

type AssociateURL

type AssociateURL interface{}

AssociateURL is return status of

type AssociateURLParams

type AssociateURLParams struct {
	URLToAdd  string   `json:"url_to_add,omitempty" validate:"url"`
	URLsToAdd []string `json:"urls_to_add,omitempty" validate:"url"`
	URLToDel  string   `json:"url_to_del,omitempty" validate:"url"`
	URLsToDel []string `json:"urls_to_del,omitempty" validate:"url"`
	Hash      string   `json:"hash,omitempty" validate:"hexidecimal"`
	Hashes    []string `json:"hashes,omitempty" validate:"hexidecimal"`
}

AssociateURLParams params needed to associate URL to hash

type CleanedTags

type CleanedTags struct {
	Tags []string `json:"tags"`
}

CleanedTags contains cleaned tags

type CleanedTagsParams

type CleanedTagsParams struct {
	Tags []string `json:"tags"`
}

CleanedTagsParams yeah

type Client

type Client struct {
	UtilsService         *UtilsService
	TagService           *TagService
	FileService          *FileService
	URLService           *URLService
	ManagePagesService   *ManagePagesService
	ManageCookiesService *ManageCookiesService
}

Client is a tiny Github client

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Client

type CurrentPages

type CurrentPages struct {
	Pages struct {
		Name     string `json:"name"`
		PageType int    `json:"page_type"`
		Selected bool   `json:"selected"`
		Pages    []struct {
			Name     string `json:"name"`
			PageType int    `json:"page_type"`
			Selected bool   `json:"selected"`
			Pages    []struct {
				Name     string `json:"name"`
				PageKey  string `json:"page_key"`
				PageType int    `json:"page_type"`
				Selected bool   `json:"selected"`
			} `json:"pages,omitempty"`
		} `json:"pages,omitempty"`
	} `json:"pages,omitempty"`
}

CurrentPages is a struct containing all current pages on client.

type DomainCookies

type DomainCookies struct {
	Cookies [][]interface{} `json:"cookies"`
}

DomainCookies is a struct containing cookies of domain

type FileMetaData

type FileMetaData struct {
	Metadata []struct {
		FileID                       int         `json:"file_id"`
		Hash                         string      `json:"hash"`
		Size                         int         `json:"size"`
		Mime                         string      `json:"mime"`
		Ext                          string      `json:"ext"`
		Width                        int         `json:"width"`
		Height                       int         `json:"height"`
		Duration                     *int        `json:"duration"`
		HasAudio                     bool        `json:"has_audio"`
		NumFrames                    *int        `json:"num_frames"`
		NumWords                     *int        `json:"num_words"`
		KnownUrls                    interface{} `json:"known_urls"`
		ServiceNamesToStatusesToTags interface{} `json:"service_names_to_statuses_to_tags,omitempty"`
	} `json:"metadata"`
}

FileMetaData contains file metadata

type FileMetaDataParams

type FileMetaDataParams struct {
	FileIds               []string `json:"file_ids"`
	Hashes                []string `json:"hashes"`
	OnlyReturnIdentifiers bool     `json:"only_return_identifiers"`
}

FileMetaDataParams is a struct containing parameters for api call

type FileSearchParams

type FileSearchParams struct {
	Tags          []string `json:"tags"`
	SystemInbox   bool     `json:"system_inbox"`
	SystemArchive bool     `json:"system_archive"`
}

FileSearchParams is a struct for parameters for file search

type FileService

type FileService struct {
	// contains filtered or unexported fields
}

FileService is a method to get file related API calls

func NewFileService

func NewFileService(httpClient *http.Client) *FileService

NewFileService returns a new FileService.

func (*FileService) AddFileToHydrus

func (s *FileService) AddFileToHydrus(accessKey string, params AddURLParams) (AddFile, *http.Response, error)

AddFileToHydrus adds a file to hydrus

addFileParams := new(AddFileParams)
addFileParams.Path = "E:\\to_import\\ayanami.jpg"

func (*FileService) GetFileMetaData

func (s *FileService) GetFileMetaData(accessKey string, params FileMetaDataParams) (FileMetaData, *http.Response, error)

GetFileMetaData returns info about files associated with url

func (*FileService) ReturnFileByHash

func (s *FileService) ReturnFileByHash(accessKey string, id string) (io.Reader, *http.Response, *HydrusError)

ReturnFileByHash returns file by hash takes apikey and string or string

func (*FileService) ReturnFileByID

func (s *FileService) ReturnFileByID(accessKey string, id int64) (io.Reader, *http.Response, *HydrusError)

ReturnFileByID returns file by ID takes apikey and int64 or string

func (*FileService) ReturnThumbnailByHash

func (s *FileService) ReturnThumbnailByHash(accessKey string, id string) (io.Reader, *http.Response, *HydrusError)

ReturnThumbnailByHash returns thumbnail file by hash takes apikey and int64

func (*FileService) ReturnThumbnailByID

func (s *FileService) ReturnThumbnailByID(accessKey string, id int64) (io.Reader, *http.Response, *HydrusError)

ReturnThumbnailByID returns thumbnail file by ID takes apikey and int64

func (*FileService) SearchForFiles

func (s *FileService) SearchForFiles(accessKey string, params FileSearchParams) (SearchFiles, *http.Response, error)

SearchForFiles returns info about files associated with url

type HydrusError

type HydrusError struct {
	Message string
	Errors  struct {
		Function string
		Field    string
		Code     int
		State    bool
		APIURI   string
	}
}

HydrusError represents a hydrus API error response

func (HydrusError) Error

func (e HydrusError) Error() string

type ManageCookiesService

type ManageCookiesService struct {
	// contains filtered or unexported fields
}

ManageCookiesService is a method to get cookie related API calls

func NewManageCookiesService

func NewManageCookiesService(httpClient *http.Client) *ManageCookiesService

NewManageCookiesService returns a new ManageCookiesService

func (*ManageCookiesService) GetCookies

func (s *ManageCookiesService) GetCookies(accessKey string, domain string) (DomainCookies, *http.Response, error)

GetCookies is a function to return json object of all cookies associated to domain.

func (*ManageCookiesService) SetCookies

func (s *ManageCookiesService) SetCookies(accessKey string, domainCookies *DomainCookies) (*http.Response, error)

SetCookies is a function to send json object of cookies associated to domain. TODO: There be dragons

type ManagePagesService

type ManagePagesService struct {
	// contains filtered or unexported fields
}

ManagePagesService is a method to get pages related API calls

func NewManagePagesService

func NewManagePagesService(httpClient *http.Client) *ManagePagesService

NewManagePagesService returns a new ManagedPagesService

func (*ManagePagesService) FocusPage

func (s *ManagePagesService) FocusPage(accessKey string) (CurrentPages, *http.Response, error)

FocusPage 'Show' a page in the main GUI, making it the current page in view. If it is already the current page, no change is made.

func (*ManagePagesService) GetCurrentPages

func (s *ManagePagesService) GetCurrentPages(accessKey string) (CurrentPages, *http.Response, error)

GetCurrentPages is a function to return json list of all currently open pages on client.

func (*ManagePagesService) GetPageInfo

func (s *ManagePagesService) GetPageInfo(accessKey string) (CurrentPages, *http.Response, error)

GetPageInfo is a function to Get information about a specific page.

type PageFocusParam

type PageFocusParam struct {
	PageKey string `json:"page_key"`
}

PageFocusParam is a struct

type PageType

type PageType int

PageType is a page type

type PermissionType

type PermissionType int

PermissionType is a permission type

type RequestNewPermissions

type RequestNewPermissions struct {
	AccessKey string `json:"access_key"`
}

RequestNewPermissions <<

type RequestNewPermissionsParams

type RequestNewPermissionsParams struct {
	Name             string   `json:"name"`              // Name associated with new access key
	BasicPermissions []string `json:"basic_permissions"` // requested permissions

}

RequestNewPermissionsParams is a struct containing params for api call

type RequestSessionKey

type RequestSessionKey struct {
	SessionKey string `json:"session_key"`
}

RequestSessionKey >>

type SearchFiles

type SearchFiles struct {
	FileIds []int `json:"file_ids"`
}

SearchFiles contains results of file search

type TagService

type TagService struct {
	// contains filtered or unexported fields
}

TagService is a method to get tag related API calls

func NewTagService

func NewTagService(httpClient *http.Client) *TagService

NewTagService returns a new TagService.

func (*TagService) AddTagsToHydrus

func (s *TagService) AddTagsToHydrus(accessKey string, params AddTagsParams) (AddTags, *http.Response, error)

AddTagsToHydrus adds tags to hashes

addURLParams := new(AddURLParams)

addURLParams.URL = "https://8ch.net/tv/res/1846574.html"
addURLParams.DestinationPageName = "kino zone"
addURLParams.ShowDestinationPage = true
var tagMap = make(map[string][]string)
tagMap["my tags"] = []string{"hama", "bema"}
addURLParams.ServiceNamesToTags = tagMap
addURL, _, err := client.AddURLService.AddURLToHydrus(accessKey, *addURLParams)
if err != nil {
	fmt.Println(err)
}

func (*TagService) CleanTags

func (s *TagService) CleanTags(accessKey string, params []string) (CleanedTags, *http.Response, error)

CleanTags returns cleaned tags from user input takes apikey and []string

func (*TagService) GetTagServices

func (s *TagService) GetTagServices(accessKey string) (TagServices, *http.Response, HydrusError)

GetTagServices returns tag services accessKey is hash from hydrus client

type TagServices

type TagServices struct {
	LocalTags       []string `json:"local_tags"`
	TagRepositories []string `json:"tag_repositories"`
}

TagServices is a list of tag services on client

type URLFiles

type URLFiles struct {
	NormalizedURL   string `json:"normalized_url"`
	URLFileStatuses []struct {
		Status int    `json:"status"`
		Hash   string `json:"hash"`
		Note   string `json:"note"`
	} `json:"url_file_statuses"`
}

URLFiles info about files asscoiated to url

type URLInfo

type URLInfo struct {
	NormalizedURL string `json:"normalized_url"`
	URLType       int    `json:"url_type"`
	URLTypeString string `json:"url_type_string"`
	MatchName     string `json:"match_name"`
	CanParse      bool   `json:"can_parse"`
}

URLInfo info about how url will be parsed by hydrus

type URLService

type URLService struct {
	// contains filtered or unexported fields
}

URLService is a method to get URL related API calls

func NewURLService

func NewURLService(httpClient *http.Client) *URLService

NewURLService returns a new URLService.

func (*URLService) AddURLToHydrus

func (s *URLService) AddURLToHydrus(accessKey string, params AddURLParams) (AddURL, *http.Response, error)

AddURLToHydrus adds a url to hydrus

addURLParams := new(AddURLParams)

addURLParams.URL = "https://8ch.net/tv/res/1846574.html"
addURLParams.DestinationPageName = "kino zone"
addURLParams.ShowDestinationPage = true
var tagMap = make(map[string][]string)
tagMap["my tags"] = []string{"hama", "bema"}
addURLParams.ServiceNamesToTags = tagMap
addURL, _, err := client.AddURLService.AddURLToHydrus(accessKey, *addURLParams)
if err != nil {
	fmt.Println(err)
}

func (*URLService) AssociateURLToHash

func (s *URLService) AssociateURLToHash(accessKey string, params AssociateURLParams) (*http.Response, error)

AssociateURLToHash adds a file to hydrus

associateURL := new(AssociateURL)
associateURL.URL = "https://"
associateURL.Hash = "sha256"
{
	"url_to_add" : "https://rule34.xxx/index.php?id=2588418&page=post&s=view",
	"hash" : "3b820114f658d768550e4e3d4f1dced3ff8db77443472b5ad93700647ad2d3ba"
}

func (*URLService) GetURLFiles

func (s *URLService) GetURLFiles(accessKey string, uri string) (URLFiles, *http.Response, HydrusError)

GetURLFiles returns info about files associated with url

func (*URLService) GetURLInfo

func (s *URLService) GetURLInfo(accessKey string, uri string) (URLInfo, *http.Response, HydrusError)

GetURLInfo returns info about how hydrus will parse provided url

type UtilsService

type UtilsService struct {
	// contains filtered or unexported fields
}

UtilsService is a method to get various utility API Calls

func NewUtilsService

func NewUtilsService(httpClient *http.Client) *UtilsService

NewUtilsService returns a new UtilsService.

func (*UtilsService) GetAPIVersion

func (s *UtilsService) GetAPIVersion() (APIVersion, *http.Response, HydrusError)

GetAPIVersion returns API version number

func (*UtilsService) GetAccessKeyStatus

func (s *UtilsService) GetAccessKeyStatus(accessKey string) (VerifyAccessKey, *http.Response, HydrusError)

GetAccessKeyStatus returns the status of provided access key accessKey is hash from hydrus client

func (*UtilsService) GetSessionKey

func (s *UtilsService) GetSessionKey(accessKey string) (RequestSessionKey, *http.Response, error)

GetSessionKey returns a session key accesskey key is hash from hydrus client

func (*UtilsService) RequestPermissions

RequestPermissions requests and returns new accesskey accesskey key is hash from hydrus client TODO: There be dragons

type VerifyAccessKey

type VerifyAccessKey struct {
	BasicPermissions []PermissionType `json:"basic_permissions"`
	HumanDescription string           `json:"human_description"`
}

VerifyAccessKey verifies access key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL