Skip to content

Commit f1ed145

Browse files
committed
Updated README with systemd instructions.
1 parent 7af966e commit f1ed145

12 files changed

+86
-46
lines changed

MANIFEST.in

-4
This file was deleted.

README

+46-26
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,58 @@ HDHOMERUN recorder
55
Description:
66
============
77
A python program to record TV programs using hdhomerun tuner device.
8-
This should run on any system capable of running python. In other
9-
words, no other dependencies other than python and apscheduler
10-
python module.
8+
This should run on any system capable of running python and
9+
hdhomerun_config binary program.
1110

1211
The hdhomerun tuner doesn't need much processing power for recording
13-
a program. So this is mainly intended for embedded systems. I use it
14-
on my WDTV Live media player.
12+
a program. So this is mainly intended for embedded systems. I used it
13+
on my WDTV Live media player. Now I use it on my pogoplug running
14+
arch Linux.
1515

1616
INSTALL:
1717
========
1818
1. Install python if you don't have it already
1919
2. Install apscheduler from here. The old version of apscheduler has
2020
some issues, so be sure to install the latest V2 version.
2121
(https://bitbucket.org/agronholm/apscheduler)
22-
3. Copy three files from this project to some place on your system
23-
1. recorder.py: The main python program
24-
2. config-file: My config file, replace at least the tuners and
25-
channelmap section with your tuner id and local channels.
26-
3. schedule-file: This is an example schedule file. Modify entries
27-
with programs you like to record.
28-
4. Copy hdhomerun_config binary to the directory that contains above
29-
files
30-
5. Run ./recorder.py and watch ./logfile for log output.
31-
32-
WDTV Live player:
33-
=================
34-
I use wdlxtv firmware (third party firmware, http://wiki.wdlxtv.com)
35-
on my WDTV Live media player. Since it does not come with python, I use
36-
optware bin and installed python using ipkg. Thanks to b-rad!
37-
38-
Link to Optware for WDLXTV Live media player:
39-
http://b-rad.cc/optware-for-wdtv/
40-
41-
Link to the actual opt.bin (be sure to install python using ipkg):
42-
http://b-rad.cc/binaries/opt.bin.tgz
22+
3. Install this package.
23+
If you have "pip", do "pip install hdhomerun-recorder"
24+
OR
25+
If you have "easy_install". do "easy_install install hdhomerun-recorder"
26+
OR
27+
You can manually download the source from PyPI
28+
(https://pypi.python.org/pypi/hdhomerun-recorder), extract and
29+
then install it using: "python setup.cfg install"
30+
31+
4. Create config-file
32+
a) Run /usr/bin/hdhomerun_recorder_setup /etc/hdhomerun_recorder/config-file
33+
This will ask few question and write your tuner and channel
34+
mappings into /etc/hdhomerun_recorder/config-file file. This
35+
will take some time as it scans your local channels
36+
37+
See /etc/hdhomerun_recorder/config-file.example to see how an
38+
example config file looks like. You may need to create one by
39+
hand if the above script fails to create one for any reason!
40+
5. Edit schedule file
41+
See /etc/hdhomerun_recorder/schedule-file.example for details.
42+
You have given schedule-file location in the config-file. Edit
43+
that file with what and when you want to record etc.
44+
6. Run /usr/bin/hdhomerun_recorder /etc/hdhomerun_recorder/config-file
45+
46+
7. Optional: See the logfile for information or errors.
47+
8. Optional. I have included /etc/hdhomerun_recorder/hdhomerun_recorder.service
48+
file that can be used to automatically start the recording daemon
49+
on reboot. You can stop, start and reload the daemon. The
50+
"reload" option is useful when you update schedule file and you
51+
want the daemon to use the changes. Of course, this only works if
52+
you have systemd based start up (latest Ubuntu, Fedora, Arch
53+
distros will have)!
54+
55+
a) Install service
56+
cp /etc/hdhomerun_recorder/hdhomerun_recorder.service /etc/systemd/system/
57+
b) Enable the service
58+
systemctl enable hdhomerun_recorder.service
59+
c) Start the service now
60+
systemctl start hdhomerun_recorder.service
61+
62+
Run "systemctl reload hdhomerun_recorder.service" whenever you change your schedule-file!

TODO

-6
This file was deleted.
File renamed without changes.

data/hdhomerun_recorder.service

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Hdhomerun tuner recording service
3+
After=openntpd.service
4+
5+
[Service]
6+
Type=simple
7+
ExecStart=/usr/bin/hdhomerun_recorder /etc/hdhomerun_recorder/config-file
8+
ExecReload=/bin/kill -HUP $MAINPID
9+
10+
[Install]
11+
WantedBy=multi-user.target
File renamed without changes.

hdhomerun_recorder/__init__.py

Whitespace-only changes.

hdhomerun_recorder.py hdhomerun_recorder/recorder.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
import os, os.path
3+
import sys, os, os.path
44
import subprocess
55
import signal, datetime
66
import logging
@@ -9,6 +9,9 @@
99
def main():
1010
from apscheduler.scheduler import Scheduler
1111

12+
if len(sys.argv) != 2:
13+
sys.exit("usage: %s <config-file>" % sys.argv[0])
14+
1215
try:
1316
from ConfigParser import ConfigParser
1417
except ImportError: # python3
@@ -19,7 +22,7 @@ def main():
1922
except TypeError: # not python3
2023
config = ConfigParser()
2124

22-
config.readfp(open('config-file'))
25+
config.readfp(open(sys.argv[1]))
2326
global logfile
2427
logfile = config.get("global", "logfile")
2528
FORMAT = "%(asctime)-15s: %(message)s"
@@ -49,20 +52,31 @@ def main():
4952
channelmap[opt] = config.get("channelmap", opt).split(",")
5053

5154
while True:
52-
global reload_jobs
55+
global reload_jobs, shutdown
5356
reload_jobs = False
57+
shutdown = False
5458
sched = Scheduler(misfire_grace_time=60, daemonic=False)
5559
sched.start()
5660
signal.signal(signal.SIGHUP, sighup_handler)
61+
signal.signal(signal.SIGTERM, sigterm_handler)
5762
schedule_jobs(sched, schedule_file, channelmap, media_dir)
58-
while not reload_jobs:
63+
while not (reload_jobs or shutdown):
5964
signal.pause()
6065
sched.shutdown()
66+
if shutdown:
67+
sys.exit(0)
6168

6269
def sighup_handler(signum, frame):
6370
global reload_jobs
71+
logging.info("Received SIGHUP, reloading schedule-file")
6472
reload_jobs = True
6573

74+
def sigterm_handler(signum, frame):
75+
# TODO: Kill any recorder threads?
76+
logging.info("Received SIGTERM, shutting down")
77+
global shutdown
78+
shutdown = True
79+
6680
def schedule_jobs(sched, schedule_file, channelmap, media_dir):
6781
import shlex
6882
for line in open(schedule_file):
File renamed without changes.

scripts/hdhomerun_recorder

100644100755
File mode changed.

scripts/hdhomerun_recorder_setup

100644100755
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env python
22

3-
pass
3+
import hdhomerun_recorder.setup
4+
5+
hdhomerun_recorder.setup.main()

setup.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
version='0.1.0',
66
author='Malahal Naineni',
77
author_email='[email protected]',
8-
py_modules=['hdhomerun_recorder'],
9-
scripts=['scripts/hdhomerun_recorder', 'scripts/hdhomerun_recorder_setup'],
10-
url='http://pypi.python.org/pypi/hdhomerun-recorder/',
118
description='hdhomerun network tuner recorder',
129
long_description=open('README').read(),
13-
#zip_safe=False,
14-
#package_data={'hdhomerun.recorder': ['config-file-example']},
10+
url='http://pypi.python.org/pypi/hdhomerun-recorder/',
11+
12+
requires=["apscheduler"],
13+
packages=['hdhomerun_recorder'],
14+
scripts=['scripts/hdhomerun_recorder', 'scripts/hdhomerun_recorder_setup'],
15+
data_files = [('/etc/hdhomerun_recorder',
16+
['data/config-file.example', 'data/schedule-file.example',
17+
'data/hdhomerun_recorder.service'])]
1518
)

0 commit comments

Comments
 (0)