parsetorrentname

package module
v0.0.0-...-3ff4efa Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: MIT Imports: 6 Imported by: 17

README

parse-torrent-name

GoDoc License Build Status Coverage Status Go Report Card

Extract media information from torrent-like filename

A Go port of Jānis' awesome library written in javascript.

Extract all possible media information present in filenames. Multiple regex rules are applied on filename string each of which extracts correponding 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.

Usage

import PTN

info = PTN.parse('A freakishly cool movie or TV episode')

print info # All details that were parsed

PTN works well for both movies and TV episodes. All meaningful information is extracted and returned together in a dictionary. The text which could not be parsed is returned in the excess field.

Movies
PTN.parse('San Andreas 2015 720p WEB-DL x264 AAC-JYK')
# {
#     'group': 'JYK',
#     'title': 'San Andreas',
#     'resolution': '720p',
#     'codec': 'x264',
#     'year':  '2015',
#     'audio': 'AAC',
#     'quality': 'WEB-DL'
# }

PTN.parse('The Martian 2015 540p HDRip KORSUB x264 AAC2 0-FGT')
# {
#     'group': '0-FGT',
#     'title': 'The Martian',
#     'resolution': '540p',
#     'excess': ['KORSUB', '2'],
#     'codec': 'x264',
#     'year': 2015,
#     'audio': 'AAC',
#     'quality': 'HDRip'
# }
TV episodes
PTN.parse('Mr Robot S01E05 HDTV x264-KILLERS[ettv]')
# {
#     'episode': 5,
#     'season': 1,
#     'title': 'Mr Robot',
#     'codec': 'x264',
#     'group':  'KILLERS[ettv]'
#     'quality': 'HDTV'
# }

PTN.parse('friends.s02e01.720p.bluray-sujaidr')
# {
#     'episode': 1,
#     'season': 2,
#     'title': 'friends',
#     'resolution': '720p',
#     'group': 'sujaidr',
#     'quality': 'bluray'    
# }
Note

PTN does not garantee the fields group, excess and episodeName as these fields might be interchanged with each other. This shoudn't affect most applications since episode name can be fetched from an online database after getting the season and episode number correctly.

Parts extracted
  • audio
  • codec
  • container
  • episode
  • episodeName
  • excess
  • extended
  • garbage
  • group
  • hardcoded
  • language
  • proper
  • quality
  • region
  • repack
  • resolution
  • season
  • title
  • website
  • widescreen
  • year

Install

Automatic

PTN can be installed using go get.

$ go get github.com/middelink/go-parse-torrent-name
Manual

First clone the repository.

$ git clone https://github.com/middelink/go-parse-torrent-name PTN && cd PTN

And run the command for installing the package.

$ go install .

Contributing

Take a look at the open issues on the original project and submit a PR!

License

MIT © Pauline Middelink

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TorrentInfo

type TorrentInfo struct {
	Title      string
	Season     int    `json:"season,omitempty"`
	Episode    int    `json:"episode,omitempty"`
	Year       int    `json:"year,omitempty"`
	Resolution string `json:"resolution,omitempty"`
	Quality    string `json:"quality,omitempty"`
	Codec      string `json:"codec,omitempty"`
	Audio      string `json:"audio,omitempty"`
	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"`
}

TorrentInfo is the resulting structure returned by Parse

func Parse

func Parse(filename string) (*TorrentInfo, error)

Parse breaks up the given filename in TorrentInfo

Jump to

Keyboard shortcuts

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