demozoo

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package demozoo interacts with the demozoo.org API for data scraping and fetching user file downloads.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequest = errors.New("unknown request value")
	ErrValues  = errors.New("too few record values")
)
View Source
var (
	ErrDir       = errors.New("filepath points to a directory")
	ErrOverwrite = errors.New("overwrite is false, but an existing download exists and cannot be overwritten")
	ErrDownload  = errors.New("no suitable downloads found")
	ErrProdAPI   = errors.New("productions api pointer cannot be nil")
	ErrRecord    = errors.New("pointer to the record cannot be nil")
	ErrRecords   = errors.New("pointer to the rows of records cannot be nil")
	ErrUUID      = errors.New("uuid is empty and cannot be used")
)
View Source
var (
	ErrAuthors  = errors.New("pointer to the author cannot be nil")
	ErrFile     = errors.New("file requirement cannot be empty")
	ErrHead     = errors.New("http header cannot be empty")
	ErrNoRel    = errors.New("no productions exist for this releaser")
	ErrParseAPI = errors.New("parse api has skipped")
	ErrProds    = errors.New("pointer to the productions cannot be nil")
)
View Source
var ErrLogger = errors.New("zap logger cannot be nil")

Functions

func Counter added in v1.11.0

func Counter(db *sql.DB, w io.Writer, r request) error

Counter prints to the writer the number of records with links to the request.

func Fix

func Fix(db *sql.DB, w io.Writer) error

Fix any Demozoo data import conflicts.

func InsertProds added in v1.6.0

func InsertProds(db *sql.DB, w io.Writer, p *releases.Productions) error

InsertProds adds the collection of Demozoo productions to the file database.

func RefreshMeta

func RefreshMeta(db *sql.DB, w io.Writer) error

RefreshMeta synchronises missing file entries with Demozoo sourced metadata.

func RefreshPouet added in v1.6.0

func RefreshPouet(db *sql.DB, w io.Writer) error

RefreshPouet synchronises missing file entries with Demozoo sourced metadata.

Types

type Category

type Category int

Category are tags for production imports.

const (
	Text     Category = iota // Text based files.
	Code                     // Code are binary files.
	Graphics                 // Graphics are images.
	Music                    // Music is audio.
	Magazine                 // Magazine are publications.
)

func (Category) String

func (c Category) String() string

type MsDosProducts added in v1.7.0

type MsDosProducts struct {
	Code   int                     // Code is the HTTP status.
	Status string                  // Status is the HTTP status.
	API    []releases.ProductionV1 // API v1 for a Demozoo production.
	Count  int                     // Count the total productions.
	Finds  int                     // Finds are the number of usable productions.
}

MsDosProducts are Demozoo productions that match platforms id 4, MS-DOS. Productions with the tag "lost" are skipped. Productions created on or newer than 1 Jan. 2000 are skipped.

func (*MsDosProducts) Get added in v1.7.0

func (m *MsDosProducts) Get(db *sql.DB, w io.Writer) error

Get all the productions on Demozoo that are for the MS-DOS platform.

type Product added in v1.6.0

type Product struct {
	Code   int                    // Code is the HTTP status.
	Status string                 // Status is the HTTP status.
	API    prods.ProductionsAPIv1 // API v1 for a Demozoo production.
}

Product is a Demozoo production item.

func (*Product) Get added in v1.6.0

func (p *Product) Get(id uint) error

Get a Demozoo production.

type Record

type Record struct {
	Count          int
	FilePath       string // FilePath is an absolute path to the file download.
	ID             string // ID is the database auto increment id.
	UUID           string // UUID is the record's unique id.
	Filename       string
	Filesize       string
	FileZipContent string
	CreatedAt      string
	UpdatedAt      string
	SumMD5         string // SumMD5 is the file download MD5 hash.
	Sum384         string // Sum384 is the file download SHA hash.
	Readme         string
	DOSeeBinary    string
	Platform       string
	GroupFor       string
	GroupBy        string
	Title          string
	Section        string
	CreditText     []string
	CreditCode     []string
	CreditArt      []string
	CreditAudio    []string
	WebIDDemozoo   uint      // WebIDDemozoo is a Demozoo ID associated with the record.
	WebIDPouet     uint      // WebIDPouet is a Pouet ID associated with the record.
	LastMod        time.Time // LastMod is the last modified time value of the file download.
}

Record update for an item in the "file" table of the database.

func NewRecord

func NewRecord(count int, values []sql.RawBytes) (Record, error)

NewRecord initialises a new file record.

func (*Record) DoseeMeta

func (r *Record) DoseeMeta(db *sql.DB, w io.Writer, cfg conf.Config) error

DoseeMeta generates DOSee related metadata from the file archive.

func (*Record) Download

func (r *Record) Download(w io.Writer, api *prods.ProductionsAPIv1, st Stat, overwrite bool) error

Download the first available remote file linked in the Demozoo production record.

func (*Record) FileMeta

func (r *Record) FileMeta() error

FileMeta generates metadata from the file archive.

func (*Record) Save

func (r *Record) Save(db *sql.DB) error

Save the record to the database.

func (*Record) Stmt added in v1.6.0

func (r *Record) Stmt() (string, []any)

Stmt creates the SQL prepare statement and values to update a Demozoo production.

func (*Record) String

func (r *Record) String() string

func (*Record) ZipContent

func (r *Record) ZipContent(w io.Writer) (bool, error)

ZipContent reads an archive and saves its content to the database.

type Records

type Records struct {
	Rows   *sql.Rows      // Rows is the result of a query.
	Args   []any          // Args are data types.
	Values []sql.RawBytes // Values are byte encoded values.
}

Records contain more than one Record.

type Releaser added in v1.6.0

type Releaser struct {
	Code   int                 // Code is the HTTP status.
	Status string              // Status is the HTTP status.
	API    releaser.ReleaserV1 // API v1 for a Demozoo releaser.
}

Releaser is a Demozoo scener or group.

func (*Releaser) Get added in v1.6.0

func (r *Releaser) Get(id uint) error

Get a Demozoo scener or group.

type ReleaserProducts added in v1.6.0

type ReleaserProducts struct {
	Code   int                  // Code is the HTTP status.
	Status string               // Status is the HTTP status.
	API    releases.Productions // API for the Demozoo productions.
}

ReleaserProducts are the productions of a Demozoo releaser.

func (*ReleaserProducts) Get added in v1.6.0

func (r *ReleaserProducts) Get(id uint) error

Get the productions of a Demozoo scener or group.

type Request

type Request struct {
	All       bool   // Parse all demozoo entries.
	Overwrite bool   // Overwrite any existing files.
	Refresh   bool   // Refresh all demozoo entries.
	ByID      string // Filter by ID.
	Config    conf.Config
	Logger    *zap.SugaredLogger
}

Request Demozoo entries.

func (Request) Queries

func (r Request) Queries(db *sql.DB, w io.Writer) error

Queries parses all new proofs. Overwrite will replace existing assets such as images. All parses every Demozoo entry, not just records waiting for approval.

func (*Request) Query

func (r *Request) Query(db *sql.DB, w io.Writer, id string) error

Query parses a single Demozoo entry.

type Stat

type Stat struct {
	Count   int    // Count records.
	Fetched int    // Fetched records.
	Missing int    // Missing files.
	Total   int    // Total files.
	ByID    string // ByID filtering.
}

Stat are statistics for the remote query.

func (*Stat) FileExist

func (st *Stat) FileExist(r *Record) (bool, error)

FileExist returns false when the record FilePath points to a non-existent file.

func (*Stat) NextPouet added in v1.6.0

func (st *Stat) NextPouet(db *sql.DB, w io.Writer, rec Records) error

NextPouet iterates over the linked Demozoo records and sync any linked Pouet data to the local files table.

func (*Stat) NextRefresh

func (st *Stat) NextRefresh(db *sql.DB, w io.Writer, rec Records) error

NextRefresh iterates over the Records to update sync their Demozoo data to the database.

type WindowsProducts added in v1.7.0

type WindowsProducts struct {
	Code   int                     // Code is the HTTP status.
	Status string                  // Status is the HTTP status.
	API    []releases.ProductionV1 // API v1 for a Demozoo production.
	Count  int                     // Count the total productions.
	Finds  int                     // Finds are the number of usable productions.
}

WindowsProducts are Demozoo productions that match the Windows platform.

func (*WindowsProducts) Get added in v1.7.0

func (m *WindowsProducts) Get(db *sql.DB, w io.Writer) error

Get all the productions on Demozoo that are for the Windows platform.

Directories

Path Synopsis
internal
filter
Package filter confirms a Demozoo Production is suitable for Defacto2.
Package filter confirms a Demozoo Production is suitable for Defacto2.
fix
Package fix repairs any imported Demozoo production data that may conflict or be incompatible with the Defacto2 database.
Package fix repairs any imported Demozoo production data that may conflict or be incompatible with the Defacto2 database.
insert
Package insert adds Demozoo productions to the Defacto2 database.
Package insert adds Demozoo productions to the Defacto2 database.
prod
Package prod obtains a Demozoo Production.
Package prod obtains a Demozoo Production.
prods
Package prods handles marshalling of a Demozoo Production.
Package prods handles marshalling of a Demozoo Production.
releaser
Package releaser handles Demozoo Releasers which are objects for both scene groups and people.
Package releaser handles Demozoo Releasers which are objects for both scene groups and people.
releases
Package releases handles collections of Demozoo Productions that share a common filter such as a platform or category type.
Package releases handles collections of Demozoo Productions that share a common filter such as a platform or category type.

Jump to

Keyboard shortcuts

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