본문 바로가기
AndroidOverLinux

[미완결]U5PVR tvhproxy 설치하기

by ㅋㅋ잠자 2017. 6. 25.
반응형

++ 실행은 정상적으로 되었지만 아직 작동하는지 여부를 테스트 해보지 않았습니다.


안녕하세요. 오늘은 U5PVR 에 tvhproxy 를 설치해 보겠습니다.


해당 패키지는 plex dvr 에 연동할 때 필요합니다. 


저는 plex pass 사용자가 아니라서 테스트를 못해보았네요.


정상작동을 아직 보장하지 않습니다.



1. 소스 받기


root@u5pvr-debian:~# git clone https://github.com/jkaberg/tvhProxy.git

Cloning into 'tvhProxy'...

remote: Counting objects: 72, done.

Unpacking objects: 100% (72/72), done.

remote: Total 72 (delta 0), reused 0 (delta 0), pack-reused 72

Checking connectivity... done.

root@u5pvr-debian:~# cd tvhProxy/

root@u5pvr-debian:~/tvhProxy# ls

AUTHORS  LICENSE  README.md  requirements.txt  tvhProxy.py  tvhProxy.service



2. 필수 패키지 설치하기


root@u5pvr-debian:~# apt-get install build-essential python-pip python-dev

Reading package lists... Done

Building dependency tree       

Reading state information... Done

build-essential is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.

root@u5pvr-debian:~# 



3. 설정하기


root@u5pvr-debian:~/tvhProxy# pip install virtualenv

Downloading/unpacking virtualenv

  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   0%  4  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   0%  8  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   0%  1  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   0%  1  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   1%  2  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   1%  2  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   1%  2  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   1%  3 .....


root@u5pvr-debian:~/tvhProxy# virtualenv venv

New python executable in /root/tvhProxy/venv/bin/python

Installing setuptools, pip, wheel...done.


root@u5pvr-debian:~/tvhProxy# . venv/bin/activate

(venv) root@u5pvr-debian:~/tvhProxy# pip install -r requirements.txt

Collecting flask (from -r requirements.txt (line 1))

  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)

    100% |################################| 92kB 537kB/s 

Collecting requests (from -r requirements.txt (line 2))

  Downloading requests-2.18.1-py2.py3-none-any.whl (88kB)

    100% |################################| 92kB 2.2MB/s 

Collecting gevent (from -r requirements.txt (line 3))

  Downloading gevent-1.2.2.tar.gz (3.1MB)

    100% |################################| 3.1MB 100kB/s 

Collecting Jinja2>=2.4 (from flask->-r requirements.txt (line 1))

  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)

    100% |################################| 348kB 755kB/s 

Collecting Werkzeug>=0.7 (from flask->-r requirements.txt (line 1))

  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)

.......



4. tvhProxy.py 설정


(venv) root@u5pvr-debian:~/tvhProxy# nano tvhProxy.py


......................................

from gevent import monkey; monkey.patch_all()


import time

import os

import requests

from gevent.pywsgi import WSGIServer

from flask import Flask, Response, request, jsonify, abort


app = Flask(__name__)


# URL format: <protocol>://<username>:<password>@<hostname>:<port>, example: https://test:1234@localho$

config = {

    'bindAddr': os.environ.get('TVH_BINDADDR') or '',

    'tvhURL': os.environ.get('TVH_URL') or 'http://localhost:19981',

    'tvhProxyURL': os.environ.get('TVH_PROXY_URL') or 'http://localhost',

    'tunerCount': os.environ.get('TVH_TUNER_COUNT') or 2,  # number of tuners in tvh

    'tvhWeight': os.environ.get('TVH_WEIGHT') or 300,  # subscription priority

    'chunkSize': os.environ.get('TVH_CHUNK_SIZE') or 1024*1024  # usually you don't need to edit this

}



@app.route('/discover.json')

def discover():

    return jsonify({

        'FriendlyName': 'tvhProxy',

        'ModelNumber': 'HDTC-2US',

        'FirmwareName': 'hdhomeruntc_atsc',

        'TunerCount': int(config['tunerCount']),

        'FirmwareVersion': '20150826',

        'DeviceID': '12345678',

        'DeviceAuth': 'test1234',

        'BaseURL': '%s' % config['tvhProxyURL'],

        'LineupURL': '%s/lineup.json' % config['tvhProxyURL']

    })

........................



5. 실행해보기


(venv) root@u5pvr-debian:~/tvhProxy# python tvhProxy.py

::ffff:192.168.0.8 - - [2017-06-25 21:47:55] "GET / HTTP/1.1" 404 342 0.015337


플렉스 패스 계정이 아니라서 테스트를 못하네요.


웹 브라우저로 5004 번으로 접근하면 아래와 같이 뜹니다.




6. PlexMediaServer 와 연동하기



7. 부팅시 자동실행 설정하기




반응형

댓글