Code Monkey home page Code Monkey logo

go-ptn's Introduction

go-ptn - Parse Torrent File Name

GoDoc License Go Report Card

Extract media information from movie and tv series filename

A port of middelink/go-parse-torrent-name awesome library.

Extract all possible media information present in filenames. Multiple regex rules are applied on filename string each of which extracts corresponding information from the filename. If a regex rule matches, the corresponding part is removed from the filename. In the end, the remaining part is taken as the title of the content.

Why?

Online APIs by providers like TMDb, TVDb and OMDb don't react to well to search queries which include any kind of extra information. To get proper results from these APIs, only the title of the content should be provided as the search query where this library comes into play. The accuracy of the results can be improved by passing in the year which can also be extracted using this library.

This port assumes the files folllow the current (2022) formats, and puts less focus on older naming styles. This port fixed some bugs with file extentions (containter) and various title issues. It includes a test file which can easily be updated as a json file.

Information extracted

below is the resulting struct that the function returns.

Title      string `json:"title,omitempty"`
Season     int    `json:"season,omitempty"`
Episode    int    `json:"episode,omitempty"`
Year       int    `json:"year,omitempty"`
Resolution string `json:"resolution,omitempty"` //1080p etc
Quality    string `json:"quality,omitempty"`
Codec      string `json:"codec,omitempty"`
Audio      string `json:"audio,omitempty"`
Service    string `json:"service,omitempty"` // NF etc
Group      string `json:"group,omitempty"`
Region     string `json:"region,omitempty"`
Extended   bool   `json:"extended,omitempty"`
Hardcoded  bool   `json:"hardcoded,omitempty"`
Proper     bool   `json:"proper,omitempty"`
Repack     bool   `json:"repack,omitempty"`
Container  string `json:"container,omitempty"`
Widescreen bool   `json:"widescreen,omitempty"`
Website    string `json:"website,omitempty"`
Language   string `json:"language,omitempty"`
Sbs        string `json:"sbs,omitempty"`
Unrated    bool   `json:"unrated,omitempty"`
Size       string `json:"size,omitempty"`
Threed     bool   `json:"3d,omitempty"`
Country    string `json:"country,omitempty"`   // two letters uppercase at the end of the title US or UK only for now
IsMovie    bool   `json:"ismovie"` // true if this is a movie, false if tv show

Usage

package main

import (
	"fmt"
	"github.com/razsteinmetz/go-ptn"
)

func main() {
	filename := "series.title.s01e03.720p.hdtv-GROUP.avi"
	info,_ := ptn.Parse(filename)
	fmt.Println(info)
}

// info has all the data you need

PTN works well for both movies and TV episodes. All meaningful information is extracted and returned together in a dictionary.

Install

Automatic

go-ptn can be installed using go get.

$ go get github.com/razsteinmetz/go-ptn

Manual

First clone the repository.

$ git clone https://github.com/razsteinmetz/go-ptn go-ptn && cd go-ptn

And run the command for installing the package.

$ go install .

go-ptn's People

Contributors

razsteinmetz avatar middelink avatar

Stargazers

Aidan Rowe avatar  avatar

Watchers

 avatar

go-ptn's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.