Skip to content

Commit 990820f

Browse files
author
Attila Szöllősi
committed
Update tvrenamr to 4.1.0
1 parent fae8b5d commit 990820f

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
script.customregex/*
22
script.customregex.zip
33
*~
4+
*.pyc

addon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ def start(self):
235235
output_format=None, organise=True, partial=False,
236236
quiet=False, recursive=False, rename_dir=None,
237237
regex=regex, season=None, show=None,
238-
show_override=None, specials=None, the=False,
239-
paths=paths)
238+
show_override=None, specials=None, symlink=False,
239+
the=False, paths=paths)
240240

241241
from tvrenamr.logs import log_buffer
242242
self.dialog.notification("Done", "Check log for more information!")

resources/lib/tvrenamr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
__copyright__ = 'Copyright 2012 George Hickman'
33
__license__ = 'MIT'
44
__title__ = 'tvrenamr'
5-
__version__ = '4.0.1'
5+
__version__ = '4.1.0'

resources/lib/tvrenamr/cli/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def rename(config, canonical, debug, dry_run, episode, # pylint: disable-msg=to
1919
ignore_filelist, log_file, log_level, name, # pylint: disable-msg=too-many-arguments
2020
no_cache, output_format, organise, partial, # pylint: disable-msg=too-many-arguments
2121
quiet, recursive, rename_dir, regex, season, # pylint: disable-msg=too-many-arguments
22-
show, show_override, specials, the, paths): # pylint: disable-msg=too-many-arguments
22+
show, show_override, specials, symlink, the, # pylint: disable-msg=too-many-arguments
23+
paths): # pylint: disable-msg=too-many-arguments
2324

2425
if debug:
2526
log_level = 10
@@ -29,9 +30,12 @@ def rename(config, canonical, debug, dry_run, episode, # pylint: disable-msg=to
2930
if dry_run or debug:
3031
start_dry_run(logger)
3132

33+
if not paths:
34+
paths = [os.getcwd()]
35+
3236
for current_dir, filename in build_file_list(paths, recursive, ignore_filelist):
3337
try:
34-
tv = TvRenamr(current_dir, debug, dry_run, no_cache)
38+
tv = TvRenamr(current_dir, debug, dry_run, symlink, no_cache)
3539

3640
_file = File(**tv.extract_details_from_file(
3741
filename,

resources/lib/tvrenamr/main.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import unicode_literals
22

33
import logging
4+
import sys
45
import os
56
import re
67
import shutil
@@ -132,11 +133,12 @@ def user_overrides(self, show_name, season, episode):
132133

133134

134135
class TvRenamr(object):
135-
def __init__(self, working_dir, debug=False, dry=False, cache=True):
136+
def __init__(self, working_dir, debug=False, dry=False, symlink=False, cache=True):
136137
self.cache = cache
137138
self.working_dir = working_dir
138139
self.dry = dry
139140
self.debug = debug
141+
self.symlink = symlink
140142

141143
def remove_part_from_multiple_episodes(self, show_name):
142144
"""Remove the string "Part " from a filename.
@@ -250,7 +252,17 @@ def rename(self, current_filepath, destination_filepath):
250252
log.debug(destination_filepath)
251253
if not self.dry and not self.debug:
252254
source_filepath = os.path.join(self.working_dir, current_filepath)
253-
shutil.move(source_filepath, destination_filepath)
255+
if self.symlink:
256+
# os.symlink doesn't work on windows with python < 3.3
257+
if os.name == 'posix' or sys.version_info >= (3, 3):
258+
os.symlink(source_filepath, destination_filepath)
259+
elif os.name == 'nt':
260+
import ctypes
261+
kernel_dll = ctypes.windll.LoadLibrary("kernel32.dll")
262+
kernel_dll.CreateSymbolicLinkA(source_filepath,
263+
destination_filepath, 0)
264+
else:
265+
shutil.move(source_filepath, destination_filepath)
254266
destination_file = os.path.split(destination_filepath)[1]
255267
log.log(26, 'Renamed: "%s"', destination_file)
256268
return destination_filepath

0 commit comments

Comments
 (0)