Add some pre-existing scripts.
This commit is contained in:
parent
848694ed11
commit
e1434f1a1e
|
@ -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
|
||||||
|
|
||||||
|
}
|
|
@ -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 i1<len(l1) and i2<len(l2):
|
||||||
|
if l1[i1][0] == l2[i2][0]: # same name
|
||||||
|
if l1[i1][2] == l2[i2][2]: # same type
|
||||||
|
if l1[i1][2]: # remember this folder for recursion
|
||||||
|
common_dirs.append((l1[i1][1], l2[i2][1]))
|
||||||
|
else:
|
||||||
|
print_local(l1[i1],'type changed')
|
||||||
|
i1 += 1
|
||||||
|
i2 += 1
|
||||||
|
elif l1[i1][0]<l2[i2][0]:
|
||||||
|
print_local(l1[i1],'removed')
|
||||||
|
i1 += 1
|
||||||
|
elif l1[i1][0]>l2[i2][0]:
|
||||||
|
print_local(l2[i2],'added')
|
||||||
|
i2 += 1
|
||||||
|
while i1<len(l1):
|
||||||
|
print_local(l1[i1],'removed')
|
||||||
|
i1 += 1
|
||||||
|
while i2<len(l2):
|
||||||
|
print_local(l2[i2],'added')
|
||||||
|
i2 += 1
|
||||||
|
# compare subfolders recursively
|
||||||
|
for sd1,sd2 in common_dirs:
|
||||||
|
compare_dirs(sd1, sd2)
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
compare_dirs(sys.argv[1], sys.argv[2])
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/env sh
|
||||||
|
find "${1:-.}" -maxdepth ${2:-1} -type f | sed -e 's/.*\.//' | tr [:upper:] [:lower:] | sort | uniq -c
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
shopt -s nullglob
|
||||||
|
for g in /sys/kernel/iommu_groups/*; do
|
||||||
|
echo "IOMMU Groups ${g##*/}:"
|
||||||
|
for d in $g/devices/*; do
|
||||||
|
echo -e "\t$(lspci -nns ${d##*/})"
|
||||||
|
done;
|
||||||
|
done;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# setf=python
|
||||||
|
|
||||||
|
# taken from stackexchange
|
||||||
|
import sys
|
||||||
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
||||||
|
def __init__(self, icon, parent=None):
|
||||||
|
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
|
||||||
|
menu = QtWidgets.QMenu(parent)
|
||||||
|
exitAction = menu.addAction("Exit")
|
||||||
|
exitAction.triggered.connect(self.exit)
|
||||||
|
self.setContextMenu(menu)
|
||||||
|
|
||||||
|
def exit(self):
|
||||||
|
QtCore.QCoreApplication.exit()
|
||||||
|
|
||||||
|
def main(iconName):
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
|
||||||
|
w = QtWidgets.QWidget()
|
||||||
|
trayIcon = SystemTrayIcon(QtGui.QIcon.fromTheme(iconName), w)
|
||||||
|
|
||||||
|
trayIcon.show()
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv[1])
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
[[ -z $1 ]] && echo 'Need a filename.' && exit
|
||||||
|
exec mv $1 $(mediainfo $1 | grep Title | head -n1 | cut -d: -f2)
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/env bash
|
||||||
|
filecount=$(ls -l | wc -l)
|
||||||
|
echo "File count: ${filecount}"
|
||||||
|
splitby=100
|
||||||
|
directory_count=$(($filecount/$splitby+1))
|
||||||
|
echo "Directories to split into: ${directory_count}"
|
||||||
|
echo "--START--"
|
||||||
|
count=0
|
||||||
|
current_dir=1
|
||||||
|
test -d $current_dir || mkdir $current_dir
|
||||||
|
overall=0
|
||||||
|
|
||||||
|
for file in *
|
||||||
|
do
|
||||||
|
# if [ $overall -eq 20 ]
|
||||||
|
# then
|
||||||
|
# break
|
||||||
|
# fi
|
||||||
|
overall=$((overall+1))
|
||||||
|
if [ -d "$file" ]
|
||||||
|
then
|
||||||
|
# echo "Not a file, skipping."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "Current file: ${file}"
|
||||||
|
count=$((count+1))
|
||||||
|
if [ $count -gt $splitby ]
|
||||||
|
then
|
||||||
|
current_dir=$((current_dir+1))
|
||||||
|
count=1
|
||||||
|
echo "Current count: ${count} (threshold overflow)"
|
||||||
|
mkdir "$current_dir"
|
||||||
|
else
|
||||||
|
echo "Current count: ${count}"
|
||||||
|
fi
|
||||||
|
echo "Moving to: ${current_dir}"
|
||||||
|
mv "$file" "$current_dir"
|
||||||
|
echo "--"
|
||||||
|
done
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# usage: $scriptname $files $output_sub_format
|
||||||
|
output_sub_format=${@: -1}
|
||||||
|
for i in $@
|
||||||
|
do
|
||||||
|
if [ ! -e "$i" ];
|
||||||
|
then
|
||||||
|
echo "File does not exist."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
index=$(ffprobe -v 8 -show_streams -select_streams s "$i" | grep index | cut --delimiter="=" -f 2)
|
||||||
|
if [ -z $index ];
|
||||||
|
then
|
||||||
|
echo "No subtitle streams found."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
ffprobe -v 8 -show_streams -select_streams "$i"
|
||||||
|
filename=${i%.*}
|
||||||
|
mkvextract "$i" tracks $index:"${filename}.en.ass"
|
||||||
|
if [ ! -z $1 ];
|
||||||
|
then
|
||||||
|
subtitleedit /convert "${filename}.en.ass" $output_sub_format 2>/dev/null | grep --color=none ass
|
||||||
|
fi
|
||||||
|
done
|
|
@ -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"))
|
||||||
|
|
Loading…
Reference in New Issue