Guides unpack.sh and rename.py (handle with care)

M

MrDoob

Guest
Original poster
felt 100 changes and a number of tests with different formats, I've now found the perfect way without much to do the movies and series automatically ->

1.) unpack
2.) renaming

to let, of course so that they are absolutely Plex compliant.

with the help of
@ur_avg_redditor

the last rest was done.

the following programs are used.

1.) Filebot
2.) a download program
// what can not handle sonar or similar //
3.) unrar
4.) nano

the next step would be to adapt the folder structure to you

// Danger \\
the scripts are adapted to my paths.

!! I therefore ask you to adapt this to your server / seedboxes. !!!

so now to the scripts or bash / python files.

1.) see below (bash file)
2.) see link (python script)

and now have fun automating.

//// INFO 2:! I use a seedbox to load the files and upload them with my PG-Server \\\\

--> python3
Code:
#!/usr/bin/env python3
import os,sys

def get_all_files(treeroot):
    for dir,subdirs,files in os.walk(treeroot):
         for f in files:
             if f in __file__: continue
             fullpath = os.path.realpath( os.path.join(dir,f) )
             extension = fullpath.split('.')[-1]
             newpath = os.path.join(dir, dir + '.' + extension)
             print('Move ' + fullpath + ' to ' + newpath   )
             os.rename(fullpath,newpath)


def main():
    top_dir="."
    # If directory not given, assume cwd
    if len(sys.argv) == 2: top_dir=sys.argv[1]
    get_all_files(top_dir)

if __name__ == '__main__' : main()

--> unpack.sh
Code:
#!/bin/bash
#22.07.2017 Unpack FILME/SERIEN unPACK/rename.py
#Function
AC=find
NM=-name
MD=-maxdepth

#############################################

#ORDNER
DIR1=~/downloads/complete

#############################################

#Ausführung unPACK FILME-SD

$AC $DIR1 $MD 8 $NM "*.rar" -execdir unrar x -o- {} \;
$AC $DIR1 $MD 8 $NM "*.sfv" -exec rm -f \{\} \;
$AC $DIR1 $MD 8 $NM "*.txt" -exec rm -f \{\} \;
$AC $DIR1 $MD 8 $NM "*.xml" -exec rm -f \{\} \;
$AC $DIR1 $MD 8 $NM "Sample" -exec rm -rf {} \;
$AC $DIR1 $MD 8 $NM "Proof" -type d -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "Screens" -type d -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "Cover" -type d -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "Subs" -type d -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "*jpg" -exec rm -f \{\} \;
$AC $DIR1 $MD 8 $NM "*jpeg" -exec rm -f \{\} \;
$AC $DIR1 $MD 8 $NM "*-sample.mkv" -exec rm -f \{\} \;
$AC $DIR1 $MD 8 $NM "*sample" -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "Screens*" -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "Covers*" -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "*.nfo" -exec rm -rf \{} \;
$AC $DIR1 $MD 8 $NM "Sample*" -exec rm -f \{} \;
$AC $DIR1 $MD 15 -mindepth 1  $NM "*.r[a0-9][r0-9]" -type f -exec rm -rf {} \;

#nfo clean
$AC $DIR1 $MD 15 $NM "*.nfo" -type f -exec rm -rf {} \;
$AC $DIR1 $MD -type d $EP -exec rmdir {} \;

#############################################

##Rechte setzten
chown -cR mrdoob:mrdoob ~/downloads/complete
chmod 750 ~/downloads/done/

##rename-files
python3 ~/scp/rename.py ~/downloads/complete/FILME-HD/
python3 ~/scp/rename.py ~/downloads/complete/FILME-SD/

##filebit-running

#Serien
filebot -script ~/.filebot/scripts/renall.groovy "/home5/mrdoob/downloads/complete/SERIEN/" -non-strict --conflict override --format "/home5/mrdoob/downloads/done/{plex}" --db TheTVDB
#Anime
#filebot -script ~/.filebot/scripts/renall.groovy "/home5/mrdoob/downloads/complete/ANIME-incom/" -non-strict --conflict override --format "/home5/mrdoob/downloads/done/{plex}" --db AniDB
#Filme-1080p
filebot -script ~/.filebot/scripts/renall.groovy "/home5/mrdoob/downloads/complete/FILME-HD/" -non-strict --conflict auto --format "/home5/mrdoob/downloads/done/FILME-1080p/{n}/{n} - {y}" --db TheMovieDB
#Filme-SD
filebot -script ~/.filebot/scripts/renall.groovy "/home5/mrdoob/downloads/complete/FILME-SD/" -non-strict --conflict auto --format "/home5/mrdoob/downloads/done/FILME-SD/{n}/{n} - {y}" --db TheMovieDB

chown -cR mrdoob:mrdoob ~/downloads/done/

##pg-server
~/rclone/rclone -v --stats=2s --no-update-modtime --ignore-existing --transfers=1 --checkers=4 --min-age=7d --update move ~/downloads/done pg:/mnt/move

exit 0
 
Last edited by a moderator:
M

MrDoob

Guest
Original poster
a short log -->
Code:
Auto-detect movie from context: [/home5/mrdoob/downloads/complete/FILME-HD/True.Grit.2010.1080p.BluRay.AC3.DTS.DL.x264-HDC.mkv]

Auto-detect movie from context: [/home5/mrdoob/downloads/complete/FILME-HD/Upgrade.2018.German.AC3.1080p.WEB.h264-CODY.mkv]

Auto-detect movie from context: [/home5/mrdoob/downloads/complete/FILME-HD/Upgrade.2018.German.DL.AC3.Dubbed.1080p.BluRay.x264-PsO.mkv]

Auto-detect movie from context: [/home5/mrdoob/downloads/complete/FILME-HD/Welcome.Home.2018.German.DL.1080p.BluRay.x264-ENCOUNTERS.mkv]

[MOVE] From [/home5/mrdoob/downloads/complete/FILME-HD/True.Grit.2010.1080p.BluRay.AC3.DTS.DL.x264-HDC.mkv] to [/home5/mrdoob/downloads/done/FILME-1080p/True Grit/True Grit - 2010.mkv]

[MOVE] From [/home5/mrdoob/downloads/complete/FILME-HD/American.Animals.2018.German.DL.AC3.5.1.DUBBED.1080p.BluRay.x264-DESTiNY.mkv] to [/home5/mrdoob/downloads/done/FILME-1080p/American Animals/American Animals - 2018.mkv]

[MOVE] From [/home5/mrdoob/downloads/complete/FILME-HD/Welcome.Home.2018.German.DL.1080p.BluRay.x264-ENCOUNTERS.mkv] to [/home5/mrdoob/downloads/done/FILME-1080p/Welcome Home/Welcome Home - 2018.mkv]

[MOVE] From [/home5/mrdoob/downloads/complete/FILME-HD/Upgrade.2018.German.AC3.1080p.WEB.h264-CODY.mkv] to [/home5/mrdoob/downloads/done/FILME-1080p/Upgrade/Upgrade - 2018.mkv]

[AUTO] Delete [/home5/mrdoob/downloads/done/FILME-1080p/Upgrade/Upgrade - 2018.mkv]
[MOVE] From [/home5/mrdoob/downloads/complete/FILME-HD/Upgrade.2018.German.DL.AC3.Dubbed.1080p.BluRay.x264-PsO.mkv] to [/home5/mrdoob/downloads/done/FILME-1080p/Upgrade/Upgrade - 2018.mkv]

Processed 5 files
Done 
\u30fe(\uff20\u2312\u30fc\u2312\uff20)\u30ce
+ filebot -script /home5/mrdoob/.filebot/scripts/renall.groovy /home5/mrdoob/downloads/complete/FILME-SD/ -non-strict --conflict auto --format '/home5/mrdoob/downloads/done/FILME-1080p/{n}/{n} - {y}' --db TheMovieDB
 
M

MrDoob

Guest
Original poster
as soon as the file is recognized twice, it will not be overwritten but deleted.

that means in the case "Upgrade 2018" was double loaded and deleted


since some people are using RSS / iRSSi to load the movies and not every release group is holding to the "scene tagging", this can happen

but do not worry, even if the same file is pulled back in 2 days,

Filebot / rename will rename the file exactly without putting you in trouble.

if you use the account --override in the rclone configuration then the file will be overwritten on GDrive.

this means in reverse. never duplicate files again.

I hope you understand what I mean by that

peace
 
Last edited by a moderator:

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads


Maintenance Donations

 

Recommend NewsGroups

Trending