#search for extract errors:
grep -nri "Failed to extract" /ffp/opt/couchpotato_data/logs/ | awk '{print $8;}' | sort | uniq

mkdir /ffp/opt/couchpotato_data/custom_plugins/filelist
cd /ffp/opt/couchpotato_data/custom_plugins/filelist
git clone
	class Filelist(MovieProvider, Base):
		cat_ids = [
			([25], ['3d']),
			([19], ['720p', '1080p', 'brrip', 'dvdr']),
			([3], ['dvdr']),
			([1], ['dvdrip', 'scr', 'r5', 'tc', 'ts', 'cam']),
		cat_backup_id = 19
	class Base(TorrentProvider):
		urls = {
			'test': '',
			'login': '',
			'login_check': '',
			'search': '',
			'baseurl': '',

#Torrent Providers:

#In order to work fine with Filelist configure this:
#Qualities -> Sizes, Edit the minimal and maximum sizes (in MB) for each quality:
#default: 700 - 7000 (see couchpotato/core/plugins/quality/
BR-Rip = 700 ... 20000

#How to force renamer to run
#Make sure the renamed movie does not contains files like *.renamed_already.ignore!
http://localhost/couchpotato/api/your-couchpotato-api-key-here/renamer.scan -> this won't work

	[viders.torrent.alpharatio] Failed to parsing AlphaRatio: Traceback (most recent call last):
	File "/********/apps/opt/couchpotato/couchpotato/core/media/_base/providers/torrent/", line 45, in _search
	size = tds[4].contents[0].strip('\n ')
	TypeError: 'NoneType' object is not callable
	In /********/apps/opt/couchpotato/couchpotato/core/media/_base/providers/torrent/ line 45:
	size = tds[5].contents[0].strip('\n ')

	Traceback (most recent call last):
	File "/********/apps/opt/couchpotato/", line 133, in <module>
	File "/********/apps/opt/couchpotato/", line 89, in run
		runCouchPotato(self.options, base_path, sys.argv[1:], data_dir = self.data_dir, log_dir = self.log_dir, Env = Env)
	File "/********/apps/opt/couchpotato/couchpotato/", line 140, in runCouchPotato
	File "/********/apps/opt/couchpotato/libs/CodernityDB/", line 43, in _inner
		res = f(*args, **kwargs)
	File "/********/apps/opt/couchpotato/libs/CodernityDB/", line 93, in open
		res = super(SuperThreadSafeDatabase, self).open(*args, **kwargs)
	File "/********/apps/opt/couchpotato/libs/CodernityDB/", line 571, in open
	File "/********/apps/opt/couchpotato/libs/CodernityDB/", line 162, in open_index
	File "/********/apps/opt/couchpotato/libs/CodernityDB/", line 1923, in _open_storage
	File "/********/apps/opt/couchpotato/libs/CodernityDB/", line 100, in open
		raise IOError("Storage doesn't exists!")
	IOError: Storage doesn't exists!
	Delete couchpotato_data/database directory. 
	Restart couchpotato.

# imdb automation

# how to completely reset/clean/clean the cache and database:
# empty the directories: cache, database, logs

Working with GIT

# -> best visual guide
# -> best interactive guide
# -> graphical clients listed

# show diff for last commit only
git log -p HEAD -1
git log -p -n 1
git log -p HEAD~1..HEAD

# --graph draw a text based graph of the commits on the left hand side of the commit messages
# --decorate adds the names of branches or tags of the commits that are shown
git log --full-history --all --graph --color --oneline --date-order
git log --full-history --all --graph --color --date-order --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"

# view changesets even though they are not referenced by any branch or tag
git reflog

# shows which files were altered and the relative number of lines added or deleted from each of them
git log --stat
git log --stat -1
git log --stat 57a6586c53bede7334d1be67b40e3c4f9cb63af9 -n 1
gitk --all -> GUI graph (run it from .git parent directory)

# shows both remote and local branches
git branch -a
# shows local branches
git branch
# shows remote branches
git branch -r

# restore file test4.txt to match the current HEAD
git reset HEAD test4.txt
git checkout -- test4.txt

# commit directly without first staging
git commit -m 'comment' -- README.txt

# display the information about the source of the clone:
git config --get remote.origin.url
git remote -v
git remote show origin

# git + ssh on port 222 (other than default 22) with ssh user gigi
git clone ssh://adrhc222/********/temp/git-try
# in ~/.ssh/config (create if not exists) put:
Host adrhc222
    Port 222
    User gigi
    ServerAliveInterval 30

# view commits on origin only
git fetch origin
git branch -a
* master
  remotes/origin/HEAD -> origin/master
git log --full-history --all --graph --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s" master..origin/master
git log --full-history --all --graph --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s" origin/readme-edits~1..origin/master

# Caching your GitHub password in Git
# see
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
git config --global credential.helper 'cache --timeout=31536000'

# create a “shared” repository which allows anyone with “group write” permissions on the folder to push into the repository
mkdir gitProject.git	-> .git it's a good practice for --bare repositories
cd gitProject.git
git init --bare --shared
# see -> post-update
cp -v hooks/post-update.sample hooks/post-update

# generation of info/refs and objects/info/packs files
cd test-bare-repository.git
man git-update-server-info
cat info/refs
cat objects/info/packs

# remove remote branch
git push origin --delete development

# create locally a project then upload to remote:
rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin
# -u option determines the creation of the remote branch master
git push -u origin master

# /etc/gitconfig
git config --system --list

# global configuration
git config --global --list
git config --global --edit -> at top you'll see the file's path (e.g. $HOME/.gitconfig)

# in a project
git config --list

# for CRLF see core.autocrlf variable
# exists in $HOME/.gitconfig
git config --global core.autocrlf input
git config --global --get core.autocrlf

# workflow example:
git clone
git checkout master
git remote add upstream
git remote -v
sudo npm install webpack-dev-server rimraf webpack -g
npm install
git fetch upstream
git merge upstream/master

# create a lightweight tag for HEAD
git tag "tag-name-here" HEAD
# list tags
git tag -n
# list tags for current branch
git describe --tags --abbrev=0
# push all tags
git push origin --tags
# push one tag
git push origin "tag-name-here"
# get all new tags
git fetch --all
# checkout tag named n3.2.2
git checkout tags/n3.2.2

# copy/duplicate repository
git clone --bare
cd old-repository.git
git push --mirror

	error: Your local changes to the following files would be overwritten by merge:
	Please, commit your changes or stash them before you can merge.
	git stash
	git stash pop

	GitCommandFailedException: GitCommandFailedException: Command 'fetch' failed in /ffp/opt/couchpotato (128):
	fatal: unable to access '': SSL certificate problem: unable to get local issuer certificate
	#ignore ssl certificate
	git config --system http.sslverify false -> set in /etc/gitconfig
	#or use the Mozilla's CA Bundle certificate:
	wget -nv -O /ffp/etc/ssl/cert.pem
	git config --system http.sslcainfo /ffp/etc/ssl/cert.pem
	# export site certificate chain
	cd $HOME
	openssl s_client -connect -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM >
	openssl x509 -in -out
	# install site certificate chain
	su root
	root@gigi:~# cat >> /etc/ssl/certs/ca-certificates.crt
	/etc/ssl/certs/ca-certificates.crt is the result of "curl-config --ca"
	sudo bash -c "echo -n | openssl s_client -showcerts -connect 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> /etc/ssl/certs/ca-certificates.crt"
Remove last commit from remote repository (e.g. origin)
git push origin +HEAD^:master
git reset --hard origin/master
This only works if the remote repository has the configuration:
        denyNonFastForwards = false

Use master branch for angular2-websocket library in package.json
    "angular2-websocket": "",
    "angular2-websocket": "git+",

Install own private repository
npm install "git+" --save generates in package.json:
"angular2-websocket": "git+"
npm install "git+" --save generates in package.json:
"angular2-websocket": "git+"

Force update from git when running npm install
npm install "git+" --force

Fork after already cloning
git clone
git remote -v
git remote rm origin
git remote add upstream
git remote add origin
git branch --set-upstream-to=origin/master
git config core.autocrlf input -> linux only
git fetch --all
git pull upstream master

Checkout a remote branch
git branch -a
* master
  remotes/origin/HEAD -> origin/master

git branch --track frames remotes/origin/frames
git checkout frames

Checkout all remote branches
git branch -a
for b in `git branch -r | grep -v -- '->'`; do echo "${b##origin/}"; done
for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done
# for already existing branches will fail with no undesirable consequences, e.g.:
fatal: A branch named 'master' already exists.

Show which remote branch is tracked by which local one
git branch -vv
git status -sb
git status | grep 'Your branch is up-to-date with'

Create a local branch then the remote counterpart
git refactor maven-modules    -> using
git push -u origin 'refactor/maven-modules'