Last active
May 1, 2022 23:37
-
-
Save saihtaM/5242283 to your computer and use it in GitHub Desktop.
TVHeadend tv_grab_url - with automatic setup script for Linux Newbies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
import os | |
import sys,stat | |
import urllib2 | |
installto = "/usr/bin/tv_grab_url" | |
def replace_line(file_name, line_num, text): | |
#Stolen from http://stackoverflow.com/questions/4719438/editing-specific-line-in-text-file-in-python | |
lines = open(file_name, 'r').readlines() | |
lines[line_num] = text | |
out = open(file_name, 'w') | |
out.writelines(lines) | |
out.close() | |
if not os.geteuid() == 0: | |
sys.exit('Script must be run as root') | |
content = urllib2.urlopen('https://gist.github.com/saihtaM/5242283/raw/tv_grab_url.py').read() | |
save = open(installto, "wb") | |
save.write(content) | |
save.close() | |
st = os.stat(installto) | |
os.chmod(installto, 0o777) #st.st_mode | stat.S_IEXEC | |
url = raw_input('Hi, and welcome to this super simple install script!\nThanks for choosing my script.\n\nThe script has been installed here '+installto+'\n\nLets configure it! Just fill in your XMLTV url below. Don\'t worry about whitespaces in front or behind the url. I\'ll strip them away :)\n\nPlease enter your XMLTV url: ') | |
replace_line(installto, 6, 'url = "'+url.strip()+'"\n') | |
os.system("/etc/init.d/tvheadend restart") | |
print "\n\nNow, go to your TVHeadend webgui. Configuration -> XMLTV.\nSelect \"tv_grab_url is a simple python version of the tv_gra...\", and check the checkbox Enable grabbing. Press Save Configuration and that's it!" | |
print "\nTo link your channels to the XMLTV, go to Configuration -> Channels. Change the dropbox 'XMLTV source' of each channel to the correct one. Press save." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please note, the following requires wget and python, you can get those with: apt-get install wget python | |
Do it automaticly (Ubuntu and systems with sudo): | |
wget https://gist.github.com/saihtaM/5242283/raw/tv_grab_url-setup.py -qO temptv_grab_url-setup.py && sudo python temptv_grab_url-setup.py && rm temptv_grab_url-setup.py | |
Do it automaticly alternative (No sudo? No problem, just make sure you're root.): | |
wget https://gist.github.com/saihtaM/5242283/raw/tv_grab_url-setup.py -qO temptv_grab_url-setup.py && python temptv_grab_url-setup.py && rm temptv_grab_url-setup.py | |
Manual install and config: | |
wget https://gist.github.com/saihtaM/5242283/raw/tv_grab_url.py -qO /usr/bin/tv_grab_url && chmod +x /usr/bin/tv_grab_url && nano +7 /usr/bin/tv_grab_url && /etc/init.d/tvheadend restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
# Copyright Mathias F. Svendsen - okey.dk | |
#Configuration zone start | |
url = "http://timefor.tv/xmltv/c81e728d9d4c2f636f067f89cc14862c" #EDIT ME | |
#Configuration zone end - Do not edit anything below here unless you know what you're doing. | |
from optparse import OptionParser | |
import urllib2 | |
parser = OptionParser(version="%prog 1.0b") | |
parser.add_option("-u", "--url", dest="url", help="Overwrite the hardcoded URL string.", metavar="URL", default=url) | |
parser.add_option("-d","--description", action="store_true",dest="description",default=False, help="Prints the description of this script") | |
parser.add_option("-c","--capabilities", dest="capabilities", action="store_true" ,help="Not sure what this is - but saw it in tv_grab_file.", default=False) | |
(options, args) = parser.parse_args() | |
if options.description is False and options.capabilities is False: | |
print urllib2.urlopen(options.url).read() | |
elif options.description is True: | |
print "tv_grab_url is a simple python version of the tv_grab_file, but instead of using a file, it downloads from an user specified XMLTV link." | |
elif options.capabilities is True: | |
print "baseline" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment