Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import os
import sys
import shutil
from pyexpander import config
from pyexpander.extract import extract_all, cleanup_temp
from pyexpander.log import get_logger
from pyexpander.postprocess import process_folder, process_file
from pyexpander.transmission import get_environmental_variables_from_transmission
logger = get_logger('handler')
def expand_torrent(torrent_path):
logger.info('Processing torrent %s' % torrent_path)
torrent_path = os.path.abspath(torrent_path)
if os.path.isdir(torrent_path):
torrent_path = os.path.join(torrent_path, '')
extract_all(torrent_path)
process_folder(torrent_path)
cleanup_temp(torrent_path)
else:
process_file(shutil.move, os.path.splitext(os.path.basename(torrent_path))[0], torrent_path)
logger.info('Done')
import os
import guessit
from pyexpander import config
from pyexpander.log import get_logger
logger = get_logger('categorize')
MUSIC_EXTENSIONS = ['.flac', '.mp3', '.ogg', '.wav']
SOFTWARE_EXTENSIONS = ['.iso', '.exe']
def get_path_video(filename):
guess = guessit.guess_file_info(filename)
if guess[u'type'] == u'episode':
series = guess.get(u'series', u'').title()
season = guess.get(u'season', u'')
return config.TV_PATH.format(series=series, season=season)
elif guess[u'type'] == u'movie':
title = guess.get(u'title', u'').title()
import os
from pyexpander.log import get_logger
logger = get_logger('transmission')
def get_environmental_variables_from_transmission():
"""
Return the environmental variables passed by transmission to the script.
:return: (full_torrent_path, torrent_name)
"""
torrent_dir = os.getenv('TR_TORRENT_DIR')
torrent_name = os.getenv('TR_TORRENT_NAME')
if torrent_dir is None or torrent_name is None:
raise Exception('Transmission environment variables were not found.')
full_path = os.path.join(torrent_dir, torrent_name)