Giter Site home page Giter Site logo

tregusti / episode-parser Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 2.0 800 KB

A javascript utility for parsing file names in a format that sometimes is used for tv shows.

JavaScript 56.21% TypeScript 43.79%
javascript javascript-utility tv-shows parsing

episode-parser's Introduction

episode-parser

CircleCI NPM release License

A javascript utility for parsing file names in a format that sometimes is used for tv shows.

It parses a file name like this Fake.Blood.2013.S07E06.Karma.Sucks.PROPER.720p.HDTV.x264-STALKERS.srt into an object with the following possible properties:

  • show, string: The name of the show, 'Fake Blood'.
  • year, integer: The release year, 2013.
  • season, integer: The season number, 7.
  • episode, integer: The episode number, 6.
  • episodeCount, integer: The count of episodes this file name includes, 1.
  • name, string: The name of the episode, 'Karma Sucks'.
  • quality, integer: The quality taken from 720p or 1080p. In this case 720.
  • source, string: Available values are 'hdtv', 'webdl', In this case 'hdtv'.
  • codec, string: Codec used, 'x264'.
  • group, string: Release group, 'STALKERS'.
  • ext, string: File extension, 'srt'.

Supported formats

Take a look in the tests for examples of what file name formats are supported.

Usage

Simply require the module and you get a parsing function that you invoke with the file name to parse:

var parser = require('episode-parser')
var filename = 'Fake Blood 2x06 I Need Blood.srt'
var result = parser(filename)
console.log(result.show) //= 'Fake Blood'
console.log(result.year) //= undefined
console.log(result.season) //= 2
console.log(result.codec) //= undefined

If the parser can't parse the file name, null will be returned. If the parser can't parse out a specific details, the property for that detail will be missing from the result.

Installation

npm install episode-parser

Versioning

This package uses semver.

Contributing

If you feel something is missing, which is highly probable since I made this for my personal needs, please create a pull request, with tests covering your case. If you feel somewhat lazy, create an issue instead and I might look into it.

Thank you

Flattr

Building good software and tools takes time. Please do support a future for this project if you are using it. Thank you!

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.