importer

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package importer parses specific .NFO and file_id.DIZ file group-packs submitted as .rar archives.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDir       = errors.New("named file points to a directory")
	ErrDownloads = errors.New("downloads directory points to a file")
	ErrNoFiles   = errors.New("release contains no files")
)

Functions

func Group

func Group(key string) string

Group return the proper group title of the key.

func PathGroup

func PathGroup(name string) string

PathGroup returns the group name or initialism extracted from the named directory path of the release. This is intended as a fallback when the file_id.diz cannot be parsed.

func UseDIZ added in v1.11.1

func UseDIZ(g, base string) bool

Do not read the file_id.diz if these named nfo files are discovered, as the included file_id.diz doesn't contain the required metadata.

Types

type Importer

type Importer struct {
	RARFile string // RARFile is the absolute path to the RAR archive file.
	Insert  bool   // Insert records to the database.
	Limit   uint   // Limit the number of subdrectories to process.
	Config  conf.Config
	Logger  *zap.SugaredLogger
}

func (Importer) Import

func (im Importer) Import(db *sql.DB, w io.Writer) error

Import the named .rar file.

type Stat

type Stat struct {
	Name      string                  // Name of the RAR archive file.
	Group     string                  // Group for the collection.
	GroupPath string                  // GroupPath is the directory path used for the group.
	DestOpen  string                  // DestOpen is the temp destination path for the extracted files.
	DestUUID  string                  // DestUUID is the temp destination path for the created UUID files.
	DIZs      int                     // DIZs file_id.diz count.
	NFOs      int                     // NFOs count.
	Others    int                     // Other types of files count.
	LastMods  Years                   // LastMods counts the last modified years.
	SubDirs   map[string]SubDirectory // Releases lists every release included in the RAR archive.
}

Stat the collection of NFO and file_id.diz files within an RAR archive.

func (*Stat) Create

func (st *Stat) Create() (records record.Records, err error)

Create a collection of records based on the extracted sub-directories, of the imported RAR file archive.

func (*Stat) Store

func (st *Stat) Store(w io.Writer, l *zap.SugaredLogger) error

Store creates a collection of UUID named, uncompressed zip archives from the extracted sub-directories, of the imported RAR file archive.

func (*Stat) Walk

func (st *Stat) Walk(name string, l *zap.SugaredLogger) error

Walk the named .rar archive file to collect information and statistics.

type SubDirectory

type SubDirectory struct {
	Title    string      // Title for the subdirectory.
	Diz      []byte      // The body of an included file_id.diz file.
	Nfo      []byte      // The body of a root information text file.
	Files    []string    // Files named that are included in the subdirectory.
	LastMods []time.Time // The file last modification times of the Files.
	Publish  time.Time   // The earliest file last modification time found in the subdirectory.
	Path     string      // Path of the subdirectory.
	Readme   string      // Readme is the filename of the information file for display.
	UUID     string      // UUID is the new unique id for the subdirectory.
	Filename string      // Filename for the UUID download.
}

SubDirectory of the RAR archive.

func (SubDirectory) Zip

func (sub SubDirectory) Zip(l *zap.SugaredLogger, dst string, sources ...string) (written int64, err error)

Zip creates an uncompressed zip archive at dst using the named file sources.

type Years

type Years map[string]int

Years counts the file last modified dates as years.

func (Years) Add

func (y Years) Add(mod time.Time) Years

Add a last modified date to the Years map.

Directories

Path Synopsis
Package record creates an object that can be written as JSON or used as a new database record.
Package record creates an object that can be written as JSON or used as a new database record.
Package zwt handles the .rar for the group Zero Waiting Time (ZWT).
Package zwt handles the .rar for the group Zero Waiting Time (ZWT).

Jump to

Keyboard shortcuts

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