From 96687e82b87cee1f298f95eb80d96bdd24de868c Mon Sep 17 00:00:00 2001 From: Grogdor Date: Mon, 22 Jun 2015 18:29:06 -0600 Subject: [PATCH 1/3] Updated FreeBSD installation instructions Tested on a fresh installation of FreeBSD 10.1-RELEASE amd64. There's no sudo or vim. All required software uses default build options (asynchronous DNS via c-ares in curl is off by default) so using packages is easier/faster. Removed "run first time manually" as it can cause permission/location issues, replaced with some configuration information. User startup scripts go into /usr/local/etc/rc.d and should not be edited to specify options. --- README.md | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1ccf689..aaee0b0 100644 --- a/README.md +++ b/README.md @@ -49,21 +49,17 @@ Linux: Docker: * You can use [razorgirl's Dockerfile](https://github.com/razorgirl/docker-couchpotato) to quickly build your own isolated app container. It's based on the Linux instructions above. For more info about Docker check out the [official website](https://www.docker.com). -FreeBSD : +FreeBSD: -* Update your ports tree `sudo portsnap fetch update` -* Install Python 2.6+ [lang/python](http://www.freshports.org/lang/python) with `cd /usr/ports/lang/python; sudo make install clean` -* Install port [databases/py-sqlite3](http://www.freshports.org/databases/py-sqlite3) with `cd /usr/ports/databases/py-sqlite3; sudo make install clean` -* Add a symlink to 'python2' `sudo ln -s /usr/local/bin/python /usr/local/bin/python2` -* Install port [ftp/libcurl](http://www.freshports.org/ftp/libcurl) with `cd /usr/ports/ftp/fpc-libcurl; sudo make install clean` -* Install port [ftp/curl](http://www.freshports.org/ftp/bcurl), deselect 'Asynchronous DNS resolution via c-ares' when prompted as part of config `cd /usr/ports/ftp/fpc-libcurl; sudo make install clean` -* Install port [textproc/docbook-xml-450](http://www.freshports.org/textproc/docbook-xml-450) with `cd /usr/ports/textproc/docbook-xml-450; sudo make install clean` -* Install port [GIT](http://git-scm.com/) with `cd /usr/ports/devel/git; sudo make install clean` -* 'cd' to the folder of your choosing. +* Become root with `su` +* Update your repo catalog `pkg update` +* Install required tools `pkg install python py27-sqlite3 fpc-libcurl docbook-xml git-lite` +* For default install location and running as root `cd /usr/local` * Run `git clone https://github.com/RuudBurger/CouchPotatoServer.git` -* Then run `sudo python CouchPotatoServer/CouchPotato.py` to start for the first time -* To run on boot copy the init script. `sudo cp CouchPotatoServer/init/freebsd /etc/rc.d/couchpotato` -* Change the paths inside the init script. `sudo vim /etc/rc.d/couchpotato` -* Make init script executable. `sudo chmod +x /etc/rc.d/couchpotato` -* Add init to startup. `sudo echo 'couchpotato_enable="YES"' >> /etc/rc.conf` +* Copy the startup script `cp CouchPotatoServer/init/freebsd /usr/local/etc/rc.d/couchpotato` +* Make startup script executable `chmod 555 /usr/local/etc/rc.d/couchpotato` +* Add startup to boot `echo 'couchpotato_enable="YES"' >> /etc/rc.conf` +* Read the options at the top of `more /usr/local/etc/rc.d/couchpotato` +* If not default install, specify options with startup flags in `ee /etc/rc.conf` +* Finally, `service couchpotato start` * Open your browser and go to: `http://server:5050/` From 2548d04495948013c32efa1cf7d9f0555382283b Mon Sep 17 00:00:00 2001 From: Grogdor Date: Tue, 23 Jun 2015 11:26:02 -0600 Subject: [PATCH 2/3] Update README.md Python meta-package handles the symlinks python to python2 to python2.7 in /usr/local/bin where user-installed software goes. Unfortunately that isn't in startup's $PATH for root, so the startup script fails. Symlinking python into the base system isn't great and will get blown away on system update, but appears to be the "best" worst way to make the startup script work for root out of the following options: 1) changing shebang in CouchPotato.py is a little brazen 2) append $PATH in the startup script, apparently bad form 3) specify /usr/local/bin/python as $command... also apparently bad form If using non-root user, /usr/local/bin is in $PATH. I'm hoping that by mentioning "running as root" a few times, the instructions are clear enough for people who understand permissions, yet simple enough for people who don't care or are in a jail(). Note that per rc.subr(8) and a quick test, $command_interpreter isn't actually used to execute $command, just to find the process. References: https://github.com/RuudBurger/CouchPotatoServer/pull/1226 https://www.freebsd.org/cgi/man.cgi?query=rc.subr&sektion=8 https://forums.freebsd.org/threads/rc_run_command-and-command_interpreter.27786/ Tested on FreeBSD 10.1-RELEASE amd64 as root, non-root with appropriate permissions, service start/status/stop, shutdown, reboot. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index aaee0b0..6cf07d9 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ FreeBSD: * Update your repo catalog `pkg update` * Install required tools `pkg install python py27-sqlite3 fpc-libcurl docbook-xml git-lite` * For default install location and running as root `cd /usr/local` +* If running as root, expects python here `ln -s /usr/local/bin/python /usr/bin/python` * Run `git clone https://github.com/RuudBurger/CouchPotatoServer.git` * Copy the startup script `cp CouchPotatoServer/init/freebsd /usr/local/etc/rc.d/couchpotato` * Make startup script executable `chmod 555 /usr/local/etc/rc.d/couchpotato` From b44a18a1de174c842a5f52ddbcfa0b8e8b44f0c3 Mon Sep 17 00:00:00 2001 From: josh4trunks Date: Sat, 1 Aug 2015 22:23:39 -0700 Subject: [PATCH 3/3] Add Emby notifications --- couchpotato/core/notifications/emby.py | 89 ++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 couchpotato/core/notifications/emby.py diff --git a/couchpotato/core/notifications/emby.py b/couchpotato/core/notifications/emby.py new file mode 100644 index 0000000..15bd64d --- /dev/null +++ b/couchpotato/core/notifications/emby.py @@ -0,0 +1,89 @@ +import json +import urllib, urllib2 + +from couchpotato.core.helpers.variable import cleanHost +from couchpotato.core.logger import CPLog +from couchpotato.core.notifications.base import Notification + + +log = CPLog(__name__) + +autoload = 'Emby' + + +class Emby(Notification): + + def notify(self, message = '', data = None, listener = None): + host = self.conf('host') + apikey = self.conf('apikey') + + host = cleanHost(host) + url = '%semby/Library/Series/Updated' % (host) + values = {} + data = urllib.urlencode(values) + + try: + req = urllib2.Request(url, data) + req.add_header('X-MediaBrowser-Token', apikey) + + response = urllib2.urlopen(req) + result = response.read() + response.close() + return True + + except (urllib2.URLError, IOError), e: + return False + + def test(self, **kwargs): + host = self.conf('host') + apikey = self.conf('apikey') + message = self.test_message + + host = cleanHost(host) + url = '%semby/Notifications/Admin' % (host) + values = {'Name': 'CouchPotato', 'Description': message, 'ImageUrl': 'https://raw.githubusercontent.com/RuudBurger/CouchPotatoServer/master/couchpotato/static/images/notify.couch.small.png'} + data = json.dumps(values) + + try: + req = urllib2.Request(url, data) + req.add_header('X-MediaBrowser-Token', apikey) + req.add_header('Content-Type', 'application/json') + + response = urllib2.urlopen(req) + result = response.read() + response.close() + return { + 'success': True + } + + except (urllib2.URLError, IOError), e: + return False + + +config = [{ + 'name': 'emby', + 'groups': [ + { + 'tab': 'notifications', + 'list': 'notification_providers', + 'name': 'emby', + 'options': [ + { + 'name': 'enabled', + 'default': 0, + 'type': 'enabler', + }, + { + 'name': 'host', + 'default': 'localhost:8096', + 'description': 'IP:Port, default localhost:8096' + }, + { + 'name': 'apikey', + 'label': 'API Key', + 'default': '', + }, + ], + } + ], +}]