parse-torrent-name icon indicating copy to clipboard operation
parse-torrent-name copied to clipboard

Not recognizing 2020 as date

Open danmarcoux opened this issue 4 years ago • 5 comments

parse-torrent-name is awesome! Unfortunately, the current version does not seem to recognize 2020 as a date.

danmarcoux avatar Feb 03 '20 03:02 danmarcoux

The regex is not viabe for the year... it only counts until 2019 https://github.com/jzjzjzj/parse-torrent-name/blob/master/parts/common.js#L12 A fix(?) could be:

  year: /([\[\(]?(\d{4})[\]\)]?)/,

That yould match any 4 digit number... (1234, 2020, 3999, etc...) it would also match 1080 which is a common resolution but in my testings there were no issues since the resolution also contains p

Underwater.2020.1080p.BluRay.x264.AAC5.1-[YTS.MX].mp4
{
    "year": 2020,
    "resolution": "1080p",
    "quality": "BluRay",
    "codec": "x264",
    "title": "Underwater",
    "group": "AAC5.1-[YTS.MX].mp4"
}

lordn-n avatar Apr 11 '20 19:04 lordn-n

@lordn-n I've had some instances where 1080 was caught as a year with your improved regex.

Therefore I propose: year: /([\[\(]?((?:19[0-9]|20[0123])[0-9])[\]\)]?)/,

which seemed to work with my limited amount of testing..

ManuelOverdijk avatar Oct 29 '20 11:10 ManuelOverdijk

@ManuelOverdijk @lordn-n @danmarcoux do you still use this package? Did you find an alternative?

angelxmoreno avatar May 19 '24 20:05 angelxmoreno

I use it as a backup. I found subliminal to be pretty good. $ pip install subliminal

# for movies from subliminal import *

file = "Battle.Star.Wars.2020.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTG.mkv"

video = Video.fromname(file) info = {key: getattr(video, key) for key in vars(video).keys()} # gives you dictionary like parse-torrent-name does.

print(info) # {'name': 'Battle.Star.Wars.2020.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTG.mkv', 'source': 'Web', 'release_group': 'NTG', 'streaming_service': 'Amazon Prime', 'resolution': '1080p', 'video_codec': 'H.264', 'audio_codec': 'Dolby Digital Plus', 'imdb_id': None, 'hashes': {}, 'size': None, 'subtitle_languages': set(), 'title': 'Battle Star Wars', 'year': 2020, 'country': None, 'alternative_titles': []}

# for TV shows from subliminal import *

file = "X-Men.97.S01E01.To.Me.My.X-Men.1080p.DSNP.WEB-DL.DDP5.1.Atmos.H.264-FLUX.mkv"

video = Video.fromname(file) info = {key: getattr(video, key) for key in vars(video).keys()} # gives you dictionary like parse-torrent-name does.

print(info) # {'name': 'X-Men.97.S01E01.To.Me.My.X-Men.1080p.DSNP.WEB-DL.DDP5.1.Atmos.H.264-FLUX.new.mkv', 'source': 'Web', 'release_group': 'FLUX.new', 'streaming_service': 'Disney+', 'resolution': '1080p', 'video_codec': 'H.264', 'audio_codec': ['Dolby Digital Plus', 'Dolby Atmos'], 'imdb_id': None, 'hashes': {}, 'size': None, 'subtitle_languages': set(), 'series': 'X-Men 97', 'season': 1, 'episodes': [1], 'title': 'To Me My X-Men', 'year': None, 'original_series': True, 'country': None, 'tvdb_id': None, 'series_tvdb_id': None, 'series_imdb_id': None, 'alternative_series': []}

For TV episodes it uses "series" whereas PTN uses "title". Subliminal uses title as the name of the episode. I did a little reassigning so it would be the same as Movies and PTN. info["episode_title"] = info.get("title") info["title"] = info.get("series")

Subliminal supposedly does downloading of subtitles, too, but I'll be darned if I get anything else to work.

danmarcoux avatar May 19 '24 21:05 danmarcoux

This got me looking deeper. subliminal is using the guessit library for getting info from a filename. And, it looks like I can use it without reassigning for episodes, etc. Still researching but it looks promising.

$ pip install guessit

info = dict(guessit("X-Men.97.S01E01.To.Me.My.X-Men.1080p.DSNP.WEB-DL.DDP5.1.Atmos.H.264-FLUX.mkv")) print(info) # {'title': 'X-Men 97', 'season': 1, 'episode': 1, 'episode_title': 'To Me My X-Men', 'screen_size': '1080p', 'streaming_service': 'Disney+', 'source': 'Web', 'audio_codec': ['Dolby Digital Plus', 'Dolby Atmos'], 'audio_channels': '5.1', 'video_codec': 'H.264', 'release_group': 'FLUX', 'container': 'mkv', 'mimetype': 'video/x-matroska', 'type': 'episode'} # # # info = dict(guessit("Battle.Star.Wars.2020.1080p.AMZN.WEB-DL.DDP5.1.H.265-NTG.mkv")) print(info) # {'title': 'Battle Star Wars', 'year': 2020, 'screen_size': '1080p', 'streaming_service': 'Amazon Prime', 'source': 'Web', 'audio_codec': 'Dolby Digital Plus', 'audio_channels': '5.1', 'video_codec': 'H.265', 'release_group': 'NTG', 'container': 'mkv', 'mimetype': 'video/x-matroska', 'type': 'movie'}

The only thing a little funky is the date (not year) returned by series like Jeopardy or Wheel of Fortune: dict(guessit("Jeopardy.2024.05.21.1080i.HDTV.AAC5.1.H.264-BTN.ts")) {'title': 'Jeopardy', 'date': datetime.date(2024, 5, 21), 'screen_size': '1080i', 'source': 'HDTV', 'audio_codec': 'AAC', 'audio_channels': '5.1', 'video_codec': 'H.264', 'release_group': 'BTN', 'container': 'ts', 'mimetype': 'text/vnd.trolltech.linguist', 'type': 'episode'}

But that will be pretty easy to take of, something along the lines of: if not info.get("year") and info.get("date"): info["year"] = info.get("date").year

danmarcoux avatar May 20 '24 23:05 danmarcoux