From e1434f1a1e41cc0c2d8d82d9ddd2a1fb1691c860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Thu, 30 Jul 2020 15:44:20 +0200 Subject: [PATCH] Add some pre-existing scripts. --- cpln.sh | 12 ++++++++++ dircompare | 47 ++++++++++++++++++++++++++++++++++++++++ lsext | 3 +++ lsiommu | 9 ++++++++ qttrayicontest | 29 +++++++++++++++++++++++++ rename_movie_by_title.sh | 3 +++ sort_files_into_folders | 39 +++++++++++++++++++++++++++++++++ sub_extract_convert | 24 ++++++++++++++++++++ torrentinfo.sh | 15 +++++++++++++ 9 files changed, 181 insertions(+) create mode 100644 cpln.sh create mode 100755 dircompare create mode 100755 lsext create mode 100755 lsiommu create mode 100755 qttrayicontest create mode 100755 rename_movie_by_title.sh create mode 100755 sort_files_into_folders create mode 100755 sub_extract_convert create mode 100755 torrentinfo.sh diff --git a/cpln.sh b/cpln.sh new file mode 100644 index 0000000..de8bfaf --- /dev/null +++ b/cpln.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +function cpln { + + for f in `ls $1` + + do + + ln $1/$f $2 && ln -sf $2/$f $1 + + done + +} diff --git a/dircompare b/dircompare new file mode 100755 index 0000000..5899231 --- /dev/null +++ b/dircompare @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# ft=python + +import os, sys + +def compare_dirs(d1: "old directory name", d2: "new directory name"): + def print_local(a, msg): + print('DIR ' if a[2] else 'FILE', a[1], msg) + # ensure validity + for d in [d1,d2]: + if not os.path.isdir(d): + raise ValueError("not a directory: " + d) + # get relative path + l1 = [(x,os.path.join(d1,x)) for x in os.listdir(d1)] + l2 = [(x,os.path.join(d2,x)) for x in os.listdir(d2)] + # determine type: directory or file? + l1 = sorted([(x,y,os.path.isdir(y)) for x,y in l1]) + l2 = sorted([(x,y,os.path.isdir(y)) for x,y in l2]) + i1 = i2 = 0 + common_dirs = [] + while i1l2[i2][0]: + print_local(l2[i2],'added') + i2 += 1 + while i1/dev/null | grep --color=none ass + fi +done \ No newline at end of file diff --git a/torrentinfo.sh b/torrentinfo.sh new file mode 100755 index 0000000..0832308 --- /dev/null +++ b/torrentinfo.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +from bencodepy import decode_from_file +import os + +filename = 'Another - TV Series [2012] - Blu-ray MKV h264 10-bit 1080p FLAC 2.0 Softsubs (Coalgirls).50781.torrent' +folder = '/home/lukas/Torrents/' +fullpath = os.path.join(folder,filename) +print(f"Full path to file: {fullpath}.") +print(f"File exists: {os.path.lexists(fullpath)}") + +torrent_pieces = decode_from_file(fullpath)[b'info'][b'files'] + +for torrent_piece in torrent_pieces: + print(torrent_piece[b'path'][0].decode("utf-8")) +