mirror of
https://github.com/zoriya/guessit.git
synced 2026-06-07 20:21:36 +00:00
Add name-only option
This commit is contained in:
@@ -22,6 +22,8 @@ def build_argument_parser():
|
||||
naming_opts = opts.add_argument_group("Naming")
|
||||
# naming_opts.add_argument('-t', '--type', dest='type', default=None,
|
||||
# help='The suggested file type: movie, episode. If undefined, type will be guessed.')
|
||||
naming_opts.add_argument('-n', '--name-only', dest='name_only', action='store_true', default=False,
|
||||
help='Parse files as name only (consider "/" and "\\" like other characters)')
|
||||
naming_opts.add_argument('-Y', '--date-year-first', action='store_true', dest='date_year_first', default=None,
|
||||
help='If short date is found, consider the first digits as the year.')
|
||||
naming_opts.add_argument('-D', '--date-day-first', action='store_true', dest='date_day_first', default=None,
|
||||
|
||||
@@ -7,6 +7,11 @@ Formatters
|
||||
from . import seps
|
||||
import regex as re
|
||||
|
||||
_excluded_clean_chars = ',:;-/\\'
|
||||
clean_chars = ""
|
||||
for sep in seps:
|
||||
if sep not in _excluded_clean_chars:
|
||||
clean_chars += sep
|
||||
|
||||
def cleanup(input_string):
|
||||
"""
|
||||
@@ -16,9 +21,8 @@ def cleanup(input_string):
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
for sep in seps:
|
||||
if sep not in ',:;-':
|
||||
input_string = input_string.replace(sep, ' ')
|
||||
for char in clean_chars:
|
||||
input_string = input_string.replace(char, ' ')
|
||||
return re.sub(' +', ' ', strip(input_string))
|
||||
|
||||
|
||||
|
||||
@@ -12,22 +12,25 @@ PATH_MARKER = Rebulk()
|
||||
PATH_MARKER.defaults(name="path", marker=True)
|
||||
|
||||
|
||||
def mark_path(input_string):
|
||||
def mark_path(input_string, context):
|
||||
"""
|
||||
Functional pattern to mark path elements.
|
||||
|
||||
:param input_string:
|
||||
:return:
|
||||
"""
|
||||
indices = list(find_all(input_string, '/'))
|
||||
indices += list(find_all(input_string, r'\\'))
|
||||
indices += [-1, len(input_string)]
|
||||
|
||||
indices.sort()
|
||||
|
||||
ret = []
|
||||
for i in range(0, len(indices) - 1):
|
||||
ret.append(Match(indices[i] + 1, indices[i + 1]))
|
||||
if context.get('name_only', False):
|
||||
ret.append(Match(0, len(input_string)))
|
||||
else:
|
||||
indices = list(find_all(input_string, '/'))
|
||||
indices += list(find_all(input_string, r'\\'))
|
||||
indices += [-1, len(input_string)]
|
||||
|
||||
indices.sort()
|
||||
|
||||
for i in range(0, len(indices) - 1):
|
||||
ret.append(Match(indices[i] + 1, indices[i + 1]))
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
+74
-1
@@ -573,4 +573,77 @@
|
||||
? "Star Wars: Episode IV - A New Hope (2004) Special Edition.MKV"
|
||||
: title: "Star Wars: Episode IV - A New Hope"
|
||||
year: 2004
|
||||
edition: Special Edition
|
||||
edition: Special Edition
|
||||
|
||||
? Dr.LiNE.The.Lorax.2012.DVDRip.LiNE.XviD.AC3.HQ.Hive-CM8.mp4
|
||||
: videoCodec: XviD
|
||||
title: Dr LiNE The Lorax
|
||||
format: DVD
|
||||
other: LiNE
|
||||
year: 2012
|
||||
audioCodec: AC3
|
||||
audioProfile: HQ
|
||||
releaseGroup: Hive-CM8
|
||||
|
||||
? Dr.LiNE.The.Lorax.2012.DVDRip.XviD.AC3.HQ.Hive-CM8.mp4
|
||||
: videoCodec: XviD
|
||||
title: Dr LiNE The Lorax
|
||||
format: DVD
|
||||
year: 2012
|
||||
audioCodec: AC3
|
||||
audioProfile: HQ
|
||||
releaseGroup: Hive-CM8
|
||||
|
||||
? Perfect Child-2007-TRUEFRENCH-TVRip.Xvid-h@mster.avi
|
||||
: releaseGroup: h@mster
|
||||
title: Perfect Child
|
||||
videoCodec: XviD
|
||||
language: French
|
||||
format: TV
|
||||
year: 2007
|
||||
|
||||
? entre.ciel.et.terre.(1994).dvdrip.h264.aac-psypeon.avi
|
||||
: audioCodec: AAC
|
||||
format: DVD
|
||||
releaseGroup: psypeon
|
||||
title: entre ciel et terre
|
||||
videoCodec: h264
|
||||
year: 1994
|
||||
|
||||
? Yves.Saint.Laurent.2013.FRENCH.DVDSCR.MD.XviD-ViVARiUM.avi
|
||||
: format: DVD
|
||||
language: French
|
||||
other:
|
||||
- MD
|
||||
- Screener
|
||||
releaseGroup: ViVARiUM
|
||||
title: Yves Saint Laurent
|
||||
videoCodec: XviD
|
||||
year: 2013
|
||||
|
||||
? Echec et Mort - Hard to Kill - Steven Seagal Multi 1080p BluRay x264 CCATS.avi
|
||||
: format: BluRay
|
||||
language: Multiple languages
|
||||
releaseGroup: CCATS
|
||||
screenSize: 1080p
|
||||
title: Echec et Mort - Hard to Kill - Steven Seagal
|
||||
videoCodec: h264
|
||||
|
||||
? Paparazzi - Timsit/Lindon (MKV 1080p tvripHD)
|
||||
: options: -n
|
||||
title: Paparazzi - Timsit/Lindon
|
||||
screenSize: 1080p
|
||||
format: HDTV
|
||||
|
||||
? some.movie.720p.bluray.x264-mind
|
||||
: title: some movie
|
||||
screenSize: 720p
|
||||
videoCodec: h264
|
||||
releaseGroup: mind
|
||||
format: BluRay
|
||||
|
||||
? Dr LiNE The Lorax 720p h264 BluRay
|
||||
: title: Dr LiNE The Lorax
|
||||
screenSize: 720p
|
||||
videoCodec: h264
|
||||
format: BluRay
|
||||
Reference in New Issue
Block a user