You are not logged in.
If you use MPD and a tiling WM you might find this script useful, expecially if you bind it to a shortcut:
#!/bin/bash
mpc play `mpc playlist | sed -e "s/^>/ /" | dmenu -i | grep -P -o "^ \d+" `
It lets you select any track from your current MPD playlist and plays it ;-)
Offline
Here is a link to a bunch of Bash Batch Image Processing Scripts I wrote a few years back.
Nothing real fancy, but very useful
What does this stuff do ? -- bbhelp
These commands run from the command line and edit/modify all the jpegs in a directory.
http://internap.dl.sourceforge.net/sour … lu2.tar.gz
BBIPS command line utility help
WARNING - most bbips commands work DIRECTLEY on your images !!!
It is recommended that you work on jpg COPIES ONLY to prevent loss of originals.bbcopy | Create a directory and COPY all images into it.
------------------
bbresize | RESIZEs all images width x height
bbrotate | ROTATEs all images clockwise x number of degrees
bbflip | FLIPs images top to bottom vertically.
bbflop | FLOPs images side to side horizontally.
bbatxt | ADDS TEXT to images.
------------------
bbborder | Creates a border on all images color x size
bbgrayscale | Converts images to Black and White
bbsepia | Converts all images to SEPIA toned x percentage
bbpaint | Simulates an oil painting on all images
bbnormalize | Normalizes all images
bbcolorize | Colorizes all images. Format rgb.
bbgamma | Gamma correct for all images
bbsolarize | Solorizes all images.
------------------
bbhelp | This lists the bbips command alias's
bbindex | Creates a index.jpg of all .jpg (not .JPG) files.
bbgzip | Creates a GZIPped file containing all the images.
------------------
bbapcom | APpend COMments to the images.
bbrecom | Displays (REads) COMments on all images.
bbwrcom | WRites COMments to all images, overwriting any existing comments.
Last edited by crouse (2008-12-04 11:52:10)
Offline
I wrote this bash script to rip dvds I get from netflix. The script uses dvdbackup and handbrake depending on what options you select.
I also like to quickly rip the discs and mail them back so you can copy the VOBs to your harddrive first using the dvdbackup multidisc mode. The multidisc handbrake mode skips the copying of VOBs.
Useful as hell for me
#!/bin/bash
#GLOBALS
DIN="/dev/dvd" #input
DOUT="/home/$USER/download/rips" #output
VBTR="4000" #bitrate
ABTR="192" #bitrate
discinfo(){
dvdbackup -i ${DIN} -I > ${DOUT}/file
TITLE=`grep information ${DOUT}/file | cut -c44-56`
TNUM=`grep containing ${DOUT}/file | cut -c43-45`
rm ${DOUT}/file
}
discinfoi(){
dvdbackup -i ${DIN} -I > ${DOUT}/file
TITLE[INDEX]=`grep information ${DOUT}/file | cut -c44-56`
TNUM[INDEX]=`grep containing ${DOUT}/file | cut -c43-45`
rm ${DOUT}/file
}
singled(){
discinfo
dvdbackup -i ${DIN} -o ${DOUT} -M
sleep 10s
handbrake -i ${DOUT}/${TITLE}/VIDEO_TS -o ${DOUT}/${TITLE}.mp4 -t ${TNUM} -U -F -f mp4 -e x264 -b ${VBTR} -B ${ABTR}
rm -rf ${DOUT}/${TITLE}
}
singleh(){
discinfo
handbrake -i ${DIN} -o ${DOUT}/${TITLE}.mp4 -L -U -F -f mp4 -e x264 -b ${VBTR} -B ${ABTR}
}
multid(){
main
INDEX=0
let INDEXA=DISC-1
while [ $INDEX -lt $DISC ]; do
discinfoi
dvdbackup -i ${DIN} -o ${DOUT} -M
if [ "$INDEX" -ne "$INDEXA" ]; then
echo "Please insert the next disc [enter]"
read CHNG
fi
let INDEX=INDEX+1
done
INDEX=0
while [ $INDEX -lt $DISC ]; do
handbrake -i ${DOUT}/${TITLE[INDEX]}/VIDEO_TS -o ${DOUT}/${TITLE[INDEX]}.mp4 -t ${TNUM[INDEX]} -U -F -f mp4 -e x264 -b ${VBTR} -B ${ABTR}
rm -rf ${DOUT}/${TITLE[INDEX]}
let INDEX=INDEX+1
done
exit
}
multih(){
main
INDEX=0
let INDEXA=DISC-1
while [ $INDEX -lt $DISC ]; do
discinfoi
handbrake -i ${DIN} -o ${DOUT}/${TITLE[INDEX]}.mp4 -L -U -F -f mp4 -e x264 -b ${VBTR} -B ${ABTR}
if [ "$INDEX" -ne "$INDEXA" ]; then
echo "Please insert the next disc [enter]"
read CHNG
fi
let INDEX=INDEX+1
done
exit
}
main(){
clear
echo "********************************************"
echo "********************************************"
echo "********************************************"
echo "****** ******"
echo "****** rdvdp 0.1 ******"
echo "****** ******"
echo "****** It's Automatic! ******"
echo "****** ******"
echo "******Will automagically rip a dvd and******"
echo "****** name it after the dvd title. ******"
echo "****** ******"
echo "****** ******"
echo "****** Use dvdbackup to dump dvd ******"
echo "****** ******"
echo "****** ******"
echo "****** ******"
echo "********************************************"
echo "********************************************"
echo "**************************************whukes"
echo " "
}
#MAIN
main
printf "Multi-Disc Mode [dvdbackup] [y]: "
read MDMD
printf "Multi-Disc Mode [handbrake] [y]: "
read MDMH
printf "Single [dvdbackup] [y]: "
read SDVD
printf "Single [handbrake]: "
read SHND
if [ -n "$MDMD" ]; then
if [ $MDMD = "y" ]; then
echo " "
printf "Enter the numbers of discs: "
read DISC
multid
fi
fi
if [ -n "$MDMH" ]; then
if [ $MDMH = "y" ]; then
echo " "
printf "Enter the numbers of discs: "
read DISC
multih
fi
fi
if [ -n "$SDVD" ]; then
if [ $SDVD = "y" ]; then
singled
fi
fi
singleh
Offline
Damn, that's useful. I had tried to write something similar but there were so many options available and I got a bit confused. How long does it take to run on a typical DVD?
[git] | [AURpkgs] | [arch-games]
Offline
Hell yeah. That should go on the script wiki for sure.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Damn, that's useful. I had tried to write something similar but there were so many options available and I got a bit confused. How long does it take to run on a typical DVD?
Really depends on your hardware. On my system (E6600 duo core w/ 2gb ram) it will take slightly less time than the length of the movie. If you use the multidisc mode that copies the VOBs it will take around 15 min per disc to copy the vobs but then rips automatically with no user intervention.
I really need to add a way to rip discs with episodes on them. That would make the script even more useful
Offline
hm, seems interesting. Though i do all my rips with dvd decryptor on windows *snickers*
Offline
Really depends on your hardware. On my system (E6600 duo core w/ 2gb ram) it will take slightly less time than the length of the movie. If you use the multidisc mode that copies the VOBs it will take around 15 min per disc to copy the vobs but then rips automatically with no user intervention.
I really need to add a way to rip discs with episodes on them. That would make the script even more useful
When you say that it takes about as long as the length of the movie, is that for encoding to compressed video + container? And the other is just time taken ripping only?
[git] | [AURpkgs] | [arch-games]
Offline
When you say that it takes about as long as the length of the movie, is that for encoding to compressed video + container? And the other is just time taken ripping only?
The length of time it takes to go from dvd to x264 mp4 is slight less than the length movie.
The time it takes to rip VOBs to your hd than goto x264 mp4 is 15 minutes longer than the previous.
So to answer your question. Yes. Sometimes I can't get handbrake to work with certain dvds without ripping vobs.
Offline
Does it have a setting to rip vobs only and then go back to them later? :]
I haven't looked much at the code, shouldn't be hard to do.
[git] | [AURpkgs] | [arch-games]
Offline
Does it have a setting to rip vobs only and then go back to them later? :]
I haven't looked much at the code, shouldn't be hard to do.
just do "dvdbackup -i /dev/dvd -o output -M"
Offline
So simple! Thanks for the tip.
[git] | [AURpkgs] | [arch-games]
Offline
Hell yeah. That should go on the script wiki for sure.
I added my MPD stat script
[git] | [AURpkgs] | [arch-games]
Offline
Guys, if you have time, post some of these to the ScriptWiki!
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
rson451 wrote:Hell yeah. That should go on the script wiki for sure.
I added my MPD stat script
Sweet. I'd post some more from this thread to the wiki but I don't want to put other people's work there without them saying ok.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
I wrote this irssi script to tab complete to the nick who most recently spoke in a channel http://rafb.net/p/StDVwR51.html
I submitted it for scripts.irssi.org, it should be up there at some point.
EDIT: Uploaded
download
view source
Last edited by Daenyth (2008-12-07 18:06:27)
[git] | [AURpkgs] | [arch-games]
Offline
So many nice scripts in here!
I kind of want to learn some 'real' scripting language like python or ruby, so here are my first steps in ruby. It copies some of my favourite config files to a remote directory (with sshfs), and then adds them to my git repository.
Plz give me your tips and improvements:P
#!/usr/bin/env ruby
MNTDIR = "/mnt/slaaf"
# [user@]remotehost:/remote/destination/dir
@rmtdir = "user@slaaf:/home/user/config_home"
@config_home = "user@slaaf:/home/user/config_home"
@config_system = "user@slaaf:/home/user/config_whuuza"
def ask()
answer = STDIN.gets.chomp
answer.downcase
if !((answer == "y") or (answer == "yes"))
puts "Aborting Mission."
return 1
else
return 0
end
end
def togit(file)
for f in file
system("cp -r #{f} #{MNTDIR}/#{f} && cd #{MNTDIR} && git add #{f}")
if $? == 0
puts "Copied #{f} to #{MNTDIR} and added it to GIT."
end
end
end
def mount(rmtdir, mntdir)
`mount | grep " on #{MNTDIR} "`
if not $? == 0
system("sshfs #{rmtdir} #{mntdir}")
status = $?
return status
else
puts "It seems something is already mounted on #{mntdir}. Do you still want to copy your stuff there (y/n)?"
status = ask()
return status
end
end
def check_dirvar(dir, var_name)
if !dir.nil?
@rmtdir = dir
return 0
else
puts "You chose to use a preset remote directory #{var_name}, but it is not set."
puts "Do you want to continue using the default remote directory " + @rmtdir + "?"
answer = ask()
return answer
end
end
def checkargs()
if ARGV[0] == "-h"
ARGV.delete_at(0)
status = check_dirvar(@config_home, "@config_home")
return status
elsif ARGV[0] == "-s"
ARGV.delete_at(0)
status = check_dirvar(@config_system, "@config_system")
return status
end
end
begin
if not ARGV.empty?
argerr = checkargs()
if argerr == 0
mnterr = mount(@rmtdir, MNTDIR)
if (mnterr == 0)
togit(ARGV)
system("fusermount -u #{MNTDIR}")
if !($? == 0)
puts "unmount failed"
end
else
puts "error mounting filesystem"
end
end
else
puts "Usage: #{$0} <file1> <file2> ..."
end
end
For lack of better words: chair, never, toothbrush, really. Ohw, and fish!
Offline
A simple python phonebook app. Trying to learn python...still lol.
#!/usr/bin/env python
# Author: Crouse
# A Simple Python Phone Book v2
import os
# Full path to the file containing the data - Adjust to your needs.
addressbook = "phonebook.txt"
# Write and Search functions
def WriteEntry_():
name = raw_input(" Enter name: ")
phone = raw_input(" Enter phone number: ")
f=open(addressbook, 'a')
f.write(name + " " + phone + '\n')
f.close()
print "\n"
print " Added: " + name + " " + phone + " to the phone list.\n"
def SearchEntry_():
os.system(['clear','cls'][os.name == 'nt'])
print "-------------------------------------------\n"
print "------ A Simple Python Phone Book v2 ------\n"
print "-----------------------------------Crouse--\n\n"
searchfor= raw_input(" Enter search term: ")
print "\n"
print "--------- RESULTS --------\n"
searchforlower=searchfor.lower()
try:
f=open(addressbook, 'r')
for line in f:
if line.lower().startswith(searchforlower):
print line.rstrip("\n")
f.close()
except:
print "Sorry - There doesn't appear to be a database yet."
print "Please create an entry first and then retry searching."
print "--------------------------\n"
# The Menu
while True:
os.system(['clear','cls'][os.name == 'nt'])
# Menu Displayed
print "-------------------------------------------\n"
print "------ A Simple Python Phone Book v2 ------\n"
print "-----------------------------------Crouse--\n"
selection = raw_input("\n\
s) Search Phonebook\n\
a) Add to Phonebook\n\
q) Quit\n\n\
What would you like to do? ")
print"\n"
# Returned Answer acted upon.
if selection == "s":
SearchEntry_()
elif selection == "a":
WriteEntry_()
elif selection == "e":
break
elif selection == "q":
break
else:
print " Not a valid Choice."
raw_input(" Hit any key to continue")
exit
A screenshot
Offline
Not much of a Ruby presence here, except for lldmer.
I've been learning my way around Hpricot and applied my knowledge to a Wikipedia screen scraper. When given an argument, it searches Wikipedia and prints back a list of search results. It also only prints out the overview of an article, not everything.
#!/usr/bin/env ruby
# Wikiscraper
# written by mentallaxative
#
require 'rubygems'
require 'hpricot'
require 'open-uri'
class Wikiscraper
def initialize(arguments)
#ARGV needs to be cleared else it ends up in 'gets'
@keyword = arguments.join(" ")
substitutions = {' ' => '+', '(' => '%28', ')' => '%29'}
substitutions.each_pair {|a,b| @keyword.gsub!(a, b) }
arguments.clear
@search_links = []
end
def main
process_search
populate_arrays
get_selection
final_page_processing
end
#open our search
def process_search
search_uri = "http://en.wikipedia.org/wiki/Special:Search?search=#{@keyword}&fulltext=Search"
@s_page = Hpricot(open(search_uri))
end
def populate_arrays
#results_data contains all search result names
results_data = (@s_page/"ul.mw-search-results/li/:not(div.mw-search-result-data)").inner_text
#search_links is an array of links of search results
(@s_page/"ul.mw-search-results"/:a).each do |ah|
@search_links << ah.attributes['href'].sub!('/wiki/', 'http://en.wikipedia.org/wiki/')
end
s_entries = []
results_data.each_line {|x| s_entries << "#{x}\r"}
#print out the search results
s_entries.each_index {|x| print "#{x+1}: #{s_entries[x]}"}
end
def get_selection
toc_string = '<table class="toc" id="toc" summary="Contents">'
puts "\nType in a entry number:"
@number = gets.chomp!.to_i-1
selection = Hpricot(open(@search_links[@number]))
#gets rid of everything after the table of contents
if selection.to_s.index(toc_string) == nil
@wiki_results = selection
else
@wiki_results = Hpricot(selection.to_s.slice(1..selection.to_s.index(toc_string)))
end
end
def final_page_processing
(@wiki_results/"table.infobox").remove
@text_body = (@wiki_results/"#bodyContent/p/:not(#coordinates)")
no_article_found = (@wiki_results/"div.noarticletext")
if not no_article_found.empty?
puts no_article_found.inner_text
else
puts((@wiki_results/"div.dablink").inner_text) #disambig info
puts "\n"
#get rid of citation marks like [1], [3], [12]
@text_body.inner_text.gsub(/\[[\w\d]{0,3}\]/, "").each {|c| puts c}
end
end
end
if ARGV.empty?
puts "Please supply a subject to search Wikipedia for."
else
scrape = Wikiscraper.new(ARGV)
scrape.main
end
Offline
So many nice scripts in here!
I kind of want to learn some 'real' scripting language like python or ruby, so here are my first steps in ruby. It copies some of my favourite config files to a remote directory (with sshfs), and then adds them to my git repository.
Plz give me your tips and improvements:P
You used Python before, didn't you? The de facto indenting style for Ruby is two spaces, not four as in Python. You don't need to use the return keyword that often--Ruby always returns the last statement made, so you can just write 'status' instead of 'return status'. I think you also forgot a ! at the end of 'answer.downcase' otherwise the answer variable won't get modified, or you could stick it at the end of gets.chomp and save one line. Your use of 0's and 1's is a bit strange to me too... personally I'd use true and false, but you're happy with it, that's okay.
Offline
You don't need to use the return keyword that often--Ruby always returns the last statement made, so you can just write 'status' instead of 'return status'.
While this may be true (perl does the same), I consider it bad style. Implicitness is nice, but I find a nice mental aid for both the coder and anyone reading the code to explicitly return. It's very easy to forget that something returns and then get the wrong result from a function.
[git] | [AURpkgs] | [arch-games]
Offline
These could be useful to others,
subconvert.py -- Converts between MicroDVD (sub) and SubRip (srt) subtitle formats
http://sysphere.org/~anrxc/local/scr/sources/subconvert
rybackup.sh -- rsync based backup script with rotating backup-snapshots and hard-links
http://sysphere.org/~anrxc/local/scr/so … ybackup.sh
sput.py -- scp upload, I got tired of tracking ports and it's quicker to edit than ~/.ssh/config
http://sysphere.org/~anrxc/local/scr/sources/sput.py
You need to install an RTFM interface.
Offline
What's the point of backing up if you're using a hardlink? If the drive dies then you lose the backup too... The point is usually to put the backup on a DIFFERENT drive
[git] | [AURpkgs] | [arch-games]
Offline
What's the point of backing up if you're using a hardlink? If the drive dies then you lose the backup too... The point is usually to put the backup on a DIFFERENT drive
he makes hardlinks on the destination. eg with the goal of doing de-duplication when storing multiple snapshots.
I think he just wanted to re-implement rsnapshot ( http://www.rsnapshot.org/ ) ;-)
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Offline