Skip to content

CamiloMM/shell-scripts

Repository files navigation


Translation-Related
google-translate.sh Automates Google Translate.
microsoft-translate.sh Automates Bing Translator.
yandex-translate.sh Automates Yandex.Translate.
mymemory-translate.sh Automates MyMemory Translated.
honyaku-translate.sh Automates Yahoo Honyaku.
compare-translations.sh Compares the various translation scripts.
Protocols & Formats
xmlentities.sh Encodes special characters for XML and HTML.
encode-uri-component.sh Encodes strings as HTTP URI components (e.g., query params).
Utilities
fpl2html.sh Converts a Foobar2000 playlist into HTML (example).
check-crc.sh Verifies CRC32s embedded in filenames.
thumb.sh Generates a single thumbnail from a video.
Downloaders
download-google-fonts.sh Downloads fonts from Google Fonts and outputs matching CSS.
sankaku-downloader.sh Downloads media from Sankaku Channel in bulk, from tags.

google-translate.sh

Google translate from your shell. Since I've reverse-engineered the web app, this might break at any moment and require fixes. Just file an issue and I'll take a look, but really, I don't even have to tell you not to use shit like this on anything resembling "production environment".

Usage:

google-translate.sh SOURCE TARGET PHRASE

Examples:

google-translate.sh auto en "Болту́н — нахо́дка для шпио́на."
google-translate.sh auto en "La croissance de l'homme ne s'effectue pas de bas en haut, mais de l'intérieur vers l'extérieur."
google-translate.sh auto en "γνῶθι σεαυτόν"
google-translate.sh auto en "馬鹿は死ななきゃ治らない。"
google-translate.sh auto en "彼女の顔は精液に包まれました"

Dependencies:

perl curl tr node

microsoft-translate.sh

This is pretty similar but uses Microsoft Translate (or Bing Translate, whatever). I've coded it after snorting http packets from a Notepad++ plugin. Same thing: if this breaks file me an issue, and I'll look into it. Note how this one specifies automatic language detection by an empty argument instead of auto. Note that it seems to have the best automatic language detection around, and honestly for some languages the translation seems better than Google Translate, which came as a surprise to me.

Note
I've considered adding a BabelFish script, but it has just a few languages, no automatic detection and the results seem to be coming all from MS translate! It would be MS translate with less features.

Usage:

microsoft-translate.sh SOURCE TARGET PHRASE

Examples:

microsoft-translate.sh '' en "Бережливость хороша, да скупость страшна"
microsoft-translate.sh '' en "猿も木から落ちる。"
microsoft-translate.sh '' pt-BR "Spaghetti alla puttanesca means spaghetti of the whore"
microsoft-translate.sh '' en "Setze jutges d'un jutjat mengen fetge d'un penjat"
microsoft-translate.sh '' en "그녀는 공포에 봤다, 정액 사방에 비행 했다."

Dependencies:

sed iconv wget

yandex-translate.sh

Another alternative translation service, probably especially good with Russian but at the same time carrying a comparable set of features to the other ones. Note the script has to query their service twice if you don't specify the language (their web app also does this). Automatic language detection is also somewhat poor for short phrases.

Usage:

yandex-translate.sh SOURCE TARGET PHRASE

Example:

yandex-translate.sh '' en "Когда я говорил, что хочу всё и сразу, то не имел в виду проблемы и неприятности."

Dependencies:

perl curl sed

mymemory-translate.sh

This is an automatic-translation-aggregator type of thing, which also seems to feature human contributions. The most surprising aspect is that the API seems to be intentionally out in the clear so it was pretty easy to add it. Automatic language detection is laughable and it may give you weird results for too-short content, so give it a spin but YMMV.

Usage:

mymemory-translate.sh SOURCE TARGET PHRASE

Example:

mymemory-translate.sh '' en "A detecção automática de idiomas desse bagulho é bem ruinzinha."

Dependencies:

perl wget grep sed curl node

honyaku-translate.sh

This is a script that automates the Yahoo Honyaku engine. It's probably best for Japanese to English, which is good, because it's the weak spot of other translation engines (not saying I expect this to do well either). The supported languages are en, ja, pt, es, ko, fr, zh, it, de, and empty string means automatic detection (which sucks saggy meat curtains, like MyMemory's).

Usage:

honyaku-translate.sh SOURCE TARGET PHRASE

Example:

honyaku-translate.sh '' en '俺の妹がこんなに可愛いわけがない'

Dependencies:

perl curl grep sed node

compare-translations.sh

This script compares the different translation engines using their respective scripts.

Usage:

compare-translations.sh PHRASE

Example:

compare-translations.sh "Niemand ist mehr Sklave, als der sich für frei hält, ohne es zu sein."
compare-translations.sh "Les opinions ont plus causé de maux sur ce petit globe que la peste et les tremblements de terre."

Dependencies:

microsoft-translate.sh google-translate.sh yandex-translate.sh mymemory-translate.sh

fpl2html.sh

This script converts a Foobar2000 playlist into an HTML list, that can be easily copy-pasted into places that accept HTML. I made it for my girlfriend to upload her playlist as a tumblr page (see it as an example). With slight editing you can do other things with playlists; there are many fields which were parsed in the script but not used.

It uses an utility called fplreader by Jacob Hipps, there's a download link there but it's 404'd so I compiled it myself, there's a copy here (Windows 7 x64) in case you don't want to compile it. Note that you'll have to compile it if you're on Linux, BSD or whatever but if you're not on Windows you're probably used to compiling stuff anyway, lol.

Usage:

fpl2html.sh path/to/playlist.fpl > path/to/playlist.html # Will take a while

Dependencies:

sed iconv perl fplreader

xmlentities.sh

This takes raw UTF-8 from STDIN and adds XML entities (valid in HTML, too), such as & and ☃.

Usage:

echo 'déjà-vu' | xmlentities.sh # 'déjà-vu'

Dependencies:

sed iconv

encode-uri-component.sh

This takes raw UTF-8 from STDIN or shell argument(s) and encodes characters for URIs, similar to the encodeURIComponent javascript method.

Usage:

echo 'déjà-vu' | encode-uri-component.sh # 'd%C3%A9j%C3%A0-vu'
encode-uri-component.sh 'déjà-vu' # 'd%C3%A9j%C3%A0-vu'

Dependencies:

perl

check-crc.sh

If you happen to download anime, you'll notice lots of files with CRCs on the filename. This tool is designed to find CRCs in files, and check if they match. Point it to a directory, and it will scan all filenames (recursively), check the ones that seem to have a valid CRC32 (SFV-compatible) in them, checksum them, see if they match, keep doing this while you have a fun time elsewhere, and give you a report at the end (either all OK or showing files that didn't match). Non-zero exit code means something went wrong, and all output is to stderr, so you can also run it as part of something else in a script.

Usage:

check-crc.sh '[Fansubs]_-_Love.Wierd.Filenames 12v2_(1080i,HE-AAC+VP9){404B00B5}.ogm'
check-crc.sh 'folder-full-of-shitty-names-to-be-renamed-after-checking-crc'

Dependencies:

find wc tr sed awk grep cat cut basename python

Note
Python (2.7) was used because it can calculate CRC32s out of the box in Windows and Linux. I'll drop this dependency if you suggest me an alternative that is either self-contained or only depends on a core language (on Node and Perl you need to install stuff and PHP's crc32 seems to load the whole "string" in memory like a retarded motherfucker). The cksum util doesn't count because it uses Ethernet's checksum algorithm.

thumb.sh

Generates a thumbnail from a video (not a page of thumnails, just a single thumbnail).

The frame selected is at 25% of the video. This is usually representative of the video, but you may want to edit the source if you think the frame at one third, or half, would be better.

Usage:

thumb.sh <video-name.ext> [thumb-name.ext]

Dependencies:

ffmpeg grep sed cut

download-google-fonts.sh

Downloads Google fonts so they can be used locally (like with NW.js) or in your own server (be careful with cross-browser format support in such a case).

The first parameter is an URL Google gives you to embed the font, like http://fonts.googleapis.com/css?family=Asap:400,700italic, and the second parameter can be an user agent string (to get fonts for a specific platform), a format name (woff/woff2/ttf), or nothing, in which case the default is ttf.

The standard output of the script will be re-written CSS that you can use to require the fonts themselves. It also supports saving fonts (and adjusting file references in the CSS) to a custom directory (third parameter).

Usage:

download-google-fonts.sh "$url" "$formatOrUserAgent" "$subdirName" > "$name.css"

Dependencies:

grep sed wget tr cut

sankaku-downloader.sh

Downloads content from Sankaku Channel, including jpeg/png images, animated gifs, webm videos, and swf flash games, from tags that you can pass to it, just as you would use on the website itself. Content is downloaded to a folder named after the tags you specified.

Usage:

sankaku-downloader.sh 'hjl brown_hair -rating:e'

Dependencies:

tr awk grep perl sed curl

Note
Directory-unsafe characters are replaced by (so you notice them very easily and do something about it, like renaming the folder to something sensible).

About

Camilo's Shell Scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages