fakku

package module
v0.0.0-...-8a90d2e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2015 License: BSD-2-Clause Imports: 12 Imported by: 1

README

This is a Go package which interacts with the fakku REST api. It gives me an 
excuse to get better with the Go programming language.

To install this library

go get github.com/DrItanium/fakku

Documentation

Overview

Categories functions

download related operations

General Information

operations related to page interaction

Categories search functions

tag related functions

Index

Constants

View Source
const (
	CategoryManga     = "manga"
	CategoryDoujinshi = "doujinshi"
	CategoryVideos    = "videos" // Is this a legal category?
)
View Source
const (
	ErrorContentDoesntExist = "Content doesn't exist"
	ErrorUnknownJsonData    = "Got unknown json data back from content request. API Change?"
	ErrorUnknownJsonLayout  = "Got an unknown layout back from content request. API Change?"
)
View Source
const (
	ResponseOk                         = 200
	ResponseNotFound                   = 404
	ResponseUnavailableForLegalReasons = 451 // got DMCA'd son
	ResponseServiceUnavailable         = 503 // Information unavailable

)

Variables

This section is empty.

Functions

func CategoryIndex

func CategoryIndex(category, name string, c interface{}) error

func DoujinshiCategoryIndex

func DoujinshiCategoryIndex(name string, c interface{}) error

func LegalCategory

func LegalCategory(category string) bool

func MangaCategoryIndex

func MangaCategoryIndex(name string, c interface{}) error

func Online

func Online() bool

checks to see if we can connect to fakku

Types

type Attribute

type Attribute struct {
	Attribute     string `json:"attribute"`
	AttributeLink string `json:"attribute_link"`
}

func (*Attribute) String

func (this *Attribute) String() string

type AttributeList

type AttributeList []Attribute

func (AttributeList) JoinString

func (this AttributeList) JoinString(separator string) string

type CommentBody

type CommentBody struct {
	Id         int64   `json:"comment_id"`
	Parent     int64   `json:"comment_attached_id"`
	Reputation float64 `json:"comment_reputation"`
	Text       string  `json:"comment_text"`
	RawDate    int64   `json:"comment_date"`
}

Most of the data returned from the fakku rest api are statements made by users in some sort of aggregation A statement can be a post, comment, or topic An aggregation can be a topic, content, user, forum,

The problem is that there are usually two aggregators (ways) which can be used to get to the same core statement The difference is the link that refers to the other aggregate embedded in the structure.

For example, there are two types of comment: user-aggregate comment and content-aggregate comment the actual content (minus the other aggregate reference) is the same between the two types.

In real terms this means:

  • a comment from a content-aggregate has the poster information in it (user-aggregate)
  • a comment from a user-aggregate has the content information in it (content-aggregate)

I view this as each statement having two aggregate references to it. - Comment has references to: User and Content - Post has references to: User and Topic - Topic has reference to: User and Forum

Notice that each statement has a reference to the user which made the statement The other aggregate is where the statement is located (Content, Topic, Forum)

This implies that a User is really just an aggregator of different types of statements A "content" is just an aggregate of Statements made by users A topic is just an aggregate of Statements made by users A forum is just an aggregate of Statements made by users

While these statements are different the concept is still the same across all types of aggregates

When dealing with the fact that there are two aggregates for each statement we have to remain cognizant of the "perspective" of how we got to that statement and where we can go and where we can go from that statement.

All of this is leading me to believe that it isn't easy to merge UserComments and ContentComments without losing some sort of perspective of where we came from.

func (*CommentBody) Date

func (this *CommentBody) Date() time.Time

type Content

type Content struct {
	Name         string
	RawUrl       string
	Description  string
	Language     string
	Category     string
	RawDate      int64
	FileSize     int64
	Favorites    int64
	CommentCount int64
	Pages        int64
	Poster       string
	RawPosterUrl string
	Tags         AttributeList `json:"content_tags"`
	Translators  AttributeList `json:"content_translators"`
	Series       AttributeList `json:"content_series"`
	Artists      AttributeList `json:"content_artists"`
	Images       struct {
		RawCover  string
		RawSample string
	}
	// contains filtered or unexported fields
}

func GetContent

func GetContent(category, name string) (*Content, error)

func (*Content) ArtistsString

func (this *Content) ArtistsString() string

func (*Content) Comments

func (this *Content) Comments() (*ContentCommentList, error)

func (*Content) CommentsPage

func (this *Content) CommentsPage(page uint) (*ContentCommentList, error)

func (*Content) Cover

func (this *Content) Cover() (image.Image, error)

func (*Content) CoverBytes

func (this *Content) CoverBytes() ([]byte, error)

func (*Content) CoverUrl

func (this *Content) CoverUrl() (*url.URL, error)

func (*Content) Date

func (this *Content) Date() time.Time

func (*Content) Downloads

func (this *Content) Downloads() (DownloadList, error)

func (*Content) PosterUrl

func (this *Content) PosterUrl() (*url.URL, error)

func (*Content) ReadOnline

func (this *Content) ReadOnline() (PageList, error)

func (*Content) RelatedContent

func (this *Content) RelatedContent() (*RelatedContentList, error)

func (*Content) RelatedContentPage

func (this *Content) RelatedContentPage(page uint) (*RelatedContentList, error)

func (*Content) Sample

func (this *Content) Sample() (image.Image, error)

func (*Content) SampleBytes

func (this *Content) SampleBytes() ([]byte, error)

func (*Content) SampleUrl

func (this *Content) SampleUrl() (*url.URL, error)

func (*Content) SaveCover

func (this *Content) SaveCover(path string, perms os.FileMode) error

func (*Content) SaveSample

func (this *Content) SaveSample(path string, perms os.FileMode) error

func (*Content) SeriesString

func (this *Content) SeriesString() string

func (*Content) TagsString

func (this *Content) TagsString() string

func (*Content) TopComments

func (this *Content) TopComments() (*ContentCommentList, error)

func (*Content) TranslatorsString

func (this *Content) TranslatorsString() string

func (*Content) UnmarshalJSON

func (c *Content) UnmarshalJSON(b []byte) error

func (*Content) Url

func (this *Content) Url() (*url.URL, error)

type ContentComment

type ContentComment struct {
	CommentBody
	Poster string `json:"comment_poster_name"`
	RawUrl string `json:"comment_poster_url"`
}

func (*ContentComment) PosterUrl

func (this *ContentComment) PosterUrl() (*url.URL, error)

func (*ContentComment) User

func (this *ContentComment) User() (*UserProfile, error)

type ContentCommentList

type ContentCommentList struct {
	Comments   []ContentComment `json:"comments"`
	PageNumber int              `json:"page"`
	Total      int              `json:"total"`
	Pages      int              `json:"pages"`
}

func ContentComments

func ContentComments(category, name string) (*ContentCommentList, error)

func ContentCommentsPage

func ContentCommentsPage(category, name string, page uint) (*ContentCommentList, error)

func ContentTopComments

func ContentTopComments(category, name string) (*ContentCommentList, error)

type ContentList

type ContentList []Content

func ControversialDoujinshi

func ControversialDoujinshi() (ContentList, error)

func ControversialManga

func ControversialManga() (ContentList, error)

func EnglishDoujinshi

func EnglishDoujinshi() (ContentList, error)

func EnglishManga

func EnglishManga() (ContentList, error)

func FavoritesDoujinshi

func FavoritesDoujinshi() (ContentList, error)

func FavoritesManga

func FavoritesManga() (ContentList, error)

func NewestDoujinshi

func NewestDoujinshi() (ContentList, error)

func NewestManga

func NewestManga() (ContentList, error)

func PopularDoujinshi

func PopularDoujinshi() (ContentList, error)

func PopularManga

func PopularManga() (ContentList, error)

type ContentSearchResults

type ContentSearchResults struct {
	Content ContentList `json:"content"`
	Total   uint        `json:"total"`
	Pages   uint        `json:"pages"`
}

func ContentSearch

func ContentSearch(terms string) (*ContentSearchResults, error)

func ContentSearchPage

func ContentSearchPage(terms string, page uint) (*ContentSearchResults, error)

type Download

type Download struct {
	Type          string  `json:"download_type"`
	RawUrl        string  `json:"download_url"`
	Info          string  `json:"download_info"`
	DownloadCount float64 `json:"download_count"`
	RawTime       float64 `json:"download_time"`
	Poster        string  `json:"download_poster"`
	RawPosterUrl  string  `json:"download_poster_url"`
}

func (*Download) PosterUrl

func (this *Download) PosterUrl() (*url.URL, error)

func (*Download) Time

func (this *Download) Time() time.Time

func (*Download) Url

func (this *Download) Url() (*url.URL, error)

type DownloadList

type DownloadList []Download

func ContentDownloads

func ContentDownloads(category, name string) (DownloadList, error)

func (DownloadList) HasDownloads

func (this DownloadList) HasDownloads() bool

type ErrorStatus

type ErrorStatus struct {
	ErrorCode    int
	ErrorMessage string `json:"error"`
	KnownError   bool
}

func (ErrorStatus) Error

func (e ErrorStatus) Error() string

type Forum

type Forum struct {
	Name        string  `json:"forum_name"`
	Description string  `json:"forum_description"`
	RawUrl      string  `json:"forum_url"`
	Posts       uint    `json:"forum_posts"`
	TopicCount  uint    `json:"forum_topics"`
	Silent      uint    `json:"forum_silent"`
	Total       uint    `json:"total"`
	Page        uint    `json:"page"`
	PageCount   uint    `json:"pages"`
	Topics      []Topic `json:"topics"`
	RecentTopic Topic   `json:"forum_recent_topic"` // this is used in some calls but not others :/
}

func (*Forum) IsSlient

func (this *Forum) IsSlient() bool

func (*Forum) Url

func (this *Forum) Url() (*url.URL, error)

type ForumCategory

type ForumCategory struct {
	Title  string  `json:"category_title"`
	Order  uint    `json:"category_order"`
	Forums []Forum `json:"forums"`
}

func GetForumCategories

func GetForumCategories() ([]ForumCategory, error)

type ForumPost

type ForumPost struct {
	Id         uint         `json:"post_id"`
	Date       uint         `json:"post_date"`
	Poster     string       `json:"post_poster"`
	PosterUrl  string       `json:"post_poster_url"`
	Text       string       `json:"post_text"`
	Image      string       `json:"post_image"`
	Thumb      string       `json:"post_thumb"`
	Reputation int          `json:"post_reputation"`
	User       *UserProfile `json:"post_user"`
}

type ForumPosts

type ForumPosts struct {
	Topic *Topic       `json:"topic"`
	Forum *Forum       `json:"forum"`
	Posts []*ForumPost `json:"posts"`
	Total uint         `json:"total"`
	Page  uint         `json:"page"`
	Pages uint         `json:"pages"`
}

func GetForumPosts

func GetForumPosts(forum, topic string) (*ForumPosts, error)

func GetForumPostsPage

func GetForumPostsPage(forum, topic string, page uint) (*ForumPosts, error)

type ForumPostsApiFunction

type ForumPostsApiFunction struct {
	Forum string
	Topic string
	// contains filtered or unexported fields
}

func (ForumPostsApiFunction) Construct

func (c ForumPostsApiFunction) Construct() string

type ForumTopics

type ForumTopics struct {
	Forum  *Forum   `json:"forum"`
	Topics []*Topic `json:"topics"`
	Total  uint     `json:"total"`
	Page   uint     `json:"page"`
	Pages  uint     `json:"pages"`
}

func GetForumTopics

func GetForumTopics(forum string) (*ForumTopics, error)

func GetForumTopicsPage

func GetForumTopicsPage(forum string, page uint) (*ForumTopics, error)

type ForumTopicsApiFunction

type ForumTopicsApiFunction struct {
	Forum string
	// contains filtered or unexported fields
}

func (ForumTopicsApiFunction) Construct

func (c ForumTopicsApiFunction) Construct() string

type FrontPageFeaturedTopics

type FrontPageFeaturedTopics struct {
	Topics []Topic `json:"topics"`
	Total  uint    `json:"total"`
}

func GetFrontPageFeaturedTopics

func GetFrontPageFeaturedTopics() (*FrontPageFeaturedTopics, error)

type FrontPageList

type FrontPageList []interface{}

type FrontPagePoll

type FrontPagePoll struct {
	Question string         `json:"poll_question"`
	RawUrl   string         `json:"poll_url"`
	Options  PollOptionList `json:"poll_options"`
}

func GetFrontPagePoll

func GetFrontPagePoll() (*FrontPagePoll, error)

func (*FrontPagePoll) UnmarshalJSON

func (c *FrontPagePoll) UnmarshalJSON(b []byte) error

func (*FrontPagePoll) Url

func (this *FrontPagePoll) Url() (*url.URL, error)

type FrontPagePosts

type FrontPagePosts struct {
	Index FrontPageList `json:"index"`
	Total uint          `json:"total"`
}

func GetFrontPage

func GetFrontPage() (*FrontPagePosts, error)

func GetFrontPagePostsPage

func GetFrontPagePostsPage(page uint) (*FrontPagePosts, error)

func (*FrontPagePosts) UnmarshalJSON

func (c *FrontPagePosts) UnmarshalJSON(b []byte) error

type GeneralInformation

type GeneralInformation struct {
	Title         string `json:"title"`
	RawUrl        string `json:"url"`
	Documentation string `json:"documentation"`
}

func GetGeneralInformation

func GetGeneralInformation() (*GeneralInformation, error)

func (*GeneralInformation) Url

func (this *GeneralInformation) Url() (*url.URL, error)

type Page

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

func (*Page) Image

func (this *Page) Image() (image.Image, error)

func (*Page) ImageBytes

func (this *Page) ImageBytes() ([]byte, error)

func (*Page) ImageUrl

func (this *Page) ImageUrl() (*url.URL, error)

func (*Page) SaveImage

func (this *Page) SaveImage(path string, perms os.FileMode) error

func (*Page) SaveThumb

func (this *Page) SaveThumb(path string, perms os.FileMode) error

func (*Page) ThumbBytes

func (this *Page) ThumbBytes() ([]byte, error)

func (*Page) ThumbUrl

func (this *Page) ThumbUrl() (*url.URL, error)

func (*Page) Thumbnail

func (this *Page) Thumbnail() (image.Image, error)

type PageList

type PageList []Page

type PollOption

type PollOption struct {
	Text  string `json:"option_text"`
	Votes uint   `json:"option_votes"`
}

func (*PollOption) String

func (this *PollOption) String() string

type PollOptionList

type PollOptionList []PollOption

type ReadOnlineContent

type ReadOnlineContent struct {
	Content Content  `json:"content"`
	Pages   PageList `json:"pages"`
}

func ReadOnline

func ReadOnline(category, name string) (*ReadOnlineContent, error)

func (*ReadOnlineContent) UnmarshalJSON

func (r *ReadOnlineContent) UnmarshalJSON(b []byte) error

type RelatedContentList

type RelatedContentList struct {
	Related ContentList `json:"related"`
	Total   uint        `json:"total"`
	Pages   uint        `json:"pages"`
}

func RelatedContent

func RelatedContent(category, name string) (*RelatedContentList, error)

func RelatedContentPage

func RelatedContentPage(category, name string, page uint) (*RelatedContentList, error)

func (*RelatedContentList) UnmarshalJSON

func (c *RelatedContentList) UnmarshalJSON(b []byte) error

type Tag

type Tag struct {
	Name           string `json:"tag_name"`
	RawUrl         string `json:"tag_url"`
	RawImageSample string `json:"tag_image_sample"`
	Description    string `json:"tag_description"`
}

func Tags

func Tags() ([]Tag, error)

func (*Tag) ImageSampleUrl

func (this *Tag) ImageSampleUrl() (*url.URL, error)

func (*Tag) Url

func (this *Tag) Url() (*url.URL, error)

type Topic

type Topic struct {
	Title        string `json:"topic_title"`
	RawUrl       string `json:"topic_url"`
	TopicTime    uint   `json:"topic_time"`
	FirstPostId  uint   `json:"topic_first_post_id"`
	LastPostId   uint   `json:"topic_last_post_id"`
	FrontPage    uint   `json:"front_page"`
	Status       uint   `json:"topic_status"`
	Vote         uint   `json:"topic_vote"`
	Type         uint   `json:"topic_type"`
	Poster       string `json:"topic_poster"`
	RawPosterUrl string `json:"topic_poster_url"`
	RawTime      int64  `json:"topic_url"`
}

func (*Topic) OnFrontPage

func (this *Topic) OnFrontPage() bool

func (*Topic) PosterUrl

func (this *Topic) PosterUrl() (*url.URL, error)

func (*Topic) Time

func (this *Topic) Time() time.Time

func (*Topic) Url

func (this *Topic) Url() (*url.URL, error)

type UnknownEntry

type UnknownEntry struct {
	Message string
}

func (UnknownEntry) Error

func (e UnknownEntry) Error() string

type UserAchievement

type UserAchievement struct {
	Name        string `json:"achievement_name"`
	Description string `json:"achievement_description"`
	RawIcon     string `json:"achievement_icon"`
	Class       string `json:"achievement_class"`
	RawDate     int64  `json:"achievement_date"`
}

func (*UserAchievement) Date

func (this *UserAchievement) Date() time.Time

func (*UserAchievement) IconUrl

func (this *UserAchievement) IconUrl() (*url.URL, error)

func (*UserAchievement) String

func (this *UserAchievement) String() string

type UserAchievementList

type UserAchievementList []UserAchievement

func GetUserAchievements

func GetUserAchievements(user string) (UserAchievementList, error)

type UserComment

type UserComment struct {
	CommentBody
	ContentName string `json:"comment_content_name"`
	RawUrl      string `json:"comment_content_url"`
}

func (*UserComment) Content

func (this *UserComment) Content() (*Content, error)

func (*UserComment) ContentUrl

func (this *UserComment) ContentUrl() (*url.URL, error)

type UserCommentList

type UserCommentList struct {
	Comments []UserComment `json:"comments"`
	Total    uint          `json:"total"`
	Pages    uint          `json:"pages"`
}

func UserComments

func UserComments(user string) (*UserCommentList, error)

func UserCommentsPage

func UserCommentsPage(user string, page uint) (*UserCommentList, error)

type UserFavorites

type UserFavorites struct {
	Favorites ContentList `json:"favorites"`
	Total     uint        `json:"total"`
	Pages     uint        `json:"pages"`
}

func GetUserFavorites

func GetUserFavorites(user string) (*UserFavorites, error)

func GetUserFavoritesPage

func GetUserFavoritesPage(user string, page uint) (*UserFavorites, error)

type UserPost

type UserPost struct {
	Id         uint   `json:"post_id"`
	RawDate    int64  `json:"post_date"`
	Text       string `json:"post_text"`
	Reputation int    `json:"post_reputation"`
	TopicTitle string `json:"post_topic_title"`
	TopicUrl   string `json:"post_topic_url"`
}

func (*UserPost) Date

func (this *UserPost) Date() time.Time

func (*UserPost) Url

func (this *UserPost) Url() (*url.URL, error)

type UserPostList

type UserPostList []UserPost

type UserPosts

type UserPosts struct {
	Posts UserPostList `json:"posts"`
	Total uint         `json:"total"`
	Pages uint         `json:"pages"`
}

func GetUserPosts

func GetUserPosts(user string) (*UserPosts, error)

func GetUserPostsPage

func GetUserPostsPage(user string, page uint) (*UserPosts, error)

type UserProfile

type UserProfile struct {
	Username            string `json:"user_username"`
	RawUrl              string `json:"user_url"`
	Rank                string `json:"user_rank"`
	RawAvatar           string `json:"user_avatar"`
	RawRegistrationDate int64  `json:"user_registration_date"`
	RawLastVisit        int64  `json:"user_last_visit"`
	Subscribed          uint   `json:"user_subscribed"`
	PostCount           uint   `json:"user_posts"`
	Topics              uint   `json:"user_topics"`
	CommentCount        uint   `json:"user_comments"`
	Signature           string `json:"user_signature"`
	ForumReputation     int    `json:"user_forum_reputation"`
	CommentReputation   int    `json:"user_comment_reputation"`
	RawGold             uint   `json:"user_gold"`
}

DAMN, I can't just have Go convert these to bools for me. I'll need to do the conversion manually

func GetUser

func GetUser(name string) (*UserProfile, error)

func (*UserProfile) AvatarUrl

func (this *UserProfile) AvatarUrl() (*url.URL, error)

func (*UserProfile) Comments

func (this *UserProfile) Comments() (*UserCommentList, error)

func (*UserProfile) CommentsPage

func (this *UserProfile) CommentsPage(page uint) (*UserCommentList, error)

func (*UserProfile) Favorites

func (this *UserProfile) Favorites() (*UserFavorites, error)

func (*UserProfile) FavoritesPage

func (this *UserProfile) FavoritesPage(page uint) (*UserFavorites, error)

func (*UserProfile) Gold

func (this *UserProfile) Gold() bool

func (*UserProfile) LastVisit

func (this *UserProfile) LastVisit() time.Time

func (*UserProfile) Posts

func (this *UserProfile) Posts() (*UserPosts, error)

func (*UserProfile) PostsPage

func (this *UserProfile) PostsPage(page uint) (*UserPosts, error)

func (*UserProfile) RegistrationDate

func (this *UserProfile) RegistrationDate() time.Time

func (*UserProfile) Url

func (this *UserProfile) Url() (*url.URL, error)

type UserTopic

type UserTopic struct {
	Title        string `json:"topic_title"`
	RawUrl       string `json:"topic_url"`
	RawTime      int64  `json:"topic_time"`
	Replies      uint   `json:"topic_replies"`
	Status       uint   `json:"topic_status"`
	Poll         uint   `json:"topic_poll"`
	LastPostId   uint   `json:"topic_last_post_id"`
	PostPreview  string `json:"topic_post_preview"`
	Poster       string `json:"topic_poster"`
	RawPosterUrl string `json:"topic_poster_url"`
}

func (*UserTopic) PosterUrl

func (this *UserTopic) PosterUrl() (*url.URL, error)

func (*UserTopic) Time

func (this *UserTopic) Time() time.Time

func (*UserTopic) Url

func (this *UserTopic) Url() (*url.URL, error)

type UserTopicList

type UserTopicList []UserTopic

type UserTopics

type UserTopics struct {
	Topics UserTopicList `json:"topics"`
	Total  uint          `json:"total"`
	Pages  uint          `json:"pages"`
}

func GetUserTopics

func GetUserTopics(user string) (*UserTopics, error)

func GetUserTopicsPage

func GetUserTopicsPage(user string, page uint) (*UserTopics, error)

type UserTopicsApiFunction

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

func (UserTopicsApiFunction) Construct

func (c UserTopicsApiFunction) Construct() string

Jump to

Keyboard shortcuts

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