Exemplo n.º 1
0
Usage: sp <filename> [-n]

The option "-n" means normal output, i.e. spaces are not protected with
a backslash.

Last update: 2017-01-09 (yyyy-mm-dd)
"""

import os
import sys

import config as cfg
from lib import fs
from lib.clipboard import text_to_clipboards

fs.check_if_available(cfg.XSEL, "Error: {} is not available!".format(cfg.XSEL))


def main():
    normal = False
    if "-n" in sys.argv:
        normal = True
        sys.argv.remove("-n")

    if len(sys.argv) == 1:
        text = os.getcwd()
    else:
        text = os.path.join(os.getcwd(), sys.argv[1])

    if not normal:
        text = text.replace(' ', r'\ ')
Exemplo n.º 2
0
encoding of the input file to UTF-8.

The result is printed to the screen.

Last update: 2017-12-16 (yyyy-mm-dd)
"""

import os
import sys
from pathlib import Path

import config as cfg
from lib import fs
from lib.process import get_simple_cmd_output

fs.check_if_available(cfg.FILE, "Error: {} is not available!".format(cfg.FILE))
fs.check_if_available(cfg.ICONV,
                      "Error: {} is not available!".format(cfg.ICONV))

force_conversion = False


def print_help():
    p = Path(sys.argv[0])
    print("""
Usage: {0} input.txt [-f] [-h|--help]

-f              force conversion (even if the input is in UTF-8)
-h, --help      this help
""".strip().format(p.name))
Exemplo n.º 3
0
#!/usr/bin/env python3
"""
Grab a twitch video in mp3.

Usage:
    twitch2mp3 VIDEO_URL
"""

import config as cfg
import os

from lib import fs, podium
from lib.process import get_simple_cmd_output

fs.check_if_available(cfg.YOUTUBE_DL,
                      "Error: {} is not available!".format(cfg.YOUTUBE_DL))
fs.check_if_available(cfg.FFMPEG,
                      "Error: {} is not available!".format(cfg.FFMPEG))


def slugify(text):
    text = text.replace('http://', '')
    text = text.replace('https://', '')
    text = text.replace('/', '_')
    text = text.replace('.', '_')
    return text


def main():
    url = input("URL of the twitch video: ")
    cmd = 'youtube-dl -g "{}"'.format(url)
Exemplo n.º 4
0
from random import shuffle
from time import sleep

from lib import fs, podium
import config as cfg


MUSIC_DIR = '/media/jabba/JIVE/mp3/sfa_scifi'
if podium.get_short_fingerprint() in ['91d6c2', '863604']:
    MUSIC_DIR = '/trash/mp3'
TRAVERSE_RECURSIVELY = True
MPLAYER = cfg.MPLAYER
MPLAYER_OPTIONS = '-endpos 00:00:60'    # play first 60 seconds; disabled when -p is used
DEFAULT_TIME = '6h55'

fs.check_if_available(MPLAYER, "Error: {} is not available!".format(MPLAYER))


class CollectMp3:
    """Collect music files recursively in a given directory."""
    def __init__(self, music_dir):
        self.music_dir = music_dir
        self.songs = []

    def traverse(self, directory):
        """Traverse directory recursively. Symlinks are skipped."""
        content = [os.path.join(directory, x) for x in os.listdir(directory)]
        dirs = sorted([x for x in content if os.path.isdir(x)])
        files = sorted([x for x in content if os.path.isfile(x)])

        for f in files:
Exemplo n.º 5
0
#!/usr/bin/env python3
"""
Convert an image file to string.

How to install Tesseract:
* https://ubuntu.flowconsult.at/linux/ocr-tesseract-text-recognition-ubuntu-14-04/
"""

import sys

import config as cfg
from lib import fs, ocr

fs.check_if_available(cfg.TESSERACT,
                      "Error: {} is not available!".format(cfg.TESSERACT))


def process(f):
    """
    Process each image file and OCR them. The result
    is printed to the stdout.
    """
    return ocr.image_file_to_string(f)


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

if __name__ == "__main__":
    if len(sys.argv) == 1:
        print('Error: provide an image file.')
        sys.exit(1)