epg2xml 실행경로에 복사한 후 python update_mychannels.py 하시면 됩니다.
혹시 channels.m3u 파일이나 epg2xml.json 파일이 다른 경로이 있다면
python update_mychannels.py m3u파일경로 json파일경로 이렇게 넣어주면 됩니다.
혹시 모르니 실행하실 때 epg2xml.json 파일은 백업하고 하세요.
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import os import sys import re reload(sys) sys.setdefaultencoding('utf-8') __version__ = '1.0.0' DEFAULT_JSON_FILE = 'epg2xml.json' DEFAULT_M3U_FILE = 'channels.m3u' RE_MY_CHANNELS = re.compile(r'"MyChannels"\s*:\s*"([^"]*)"') def update_channel_enabled(): json_file = DEFAULT_JSON_FILE m3u_file = DEFAULT_M3U_FILE for argv in sys.argv: filename = os.path.basename(argv) if filename == 'epg2xml.json': json_file = argv elif os.path.splitext(filename)[1] == '.m3u': m3u_file = argv used_channels = get_used_channels(m3u_file) new_my_channels = ','.join(used_channels) print_log('epg2xml.json 파일의 "MyChannels"를 수정합니다.') try: with open(json_file, 'r+') as f: lines = [] for line in f: rs = RE_MY_CHANNELS.search(line) if rs is not None: line = line.replace(rs.group(1), new_my_channels) lines.append(line) f.seek(0) f.writelines(lines) f.truncate() except IOError: print_error(json_file + ' 파일을 기록할 수 없습니다.') sys.exit() print_log('epg2xml.json 파일의 "MyChannels" 수정을 완료했습니다.') def get_used_channels(channel_file): print_log('사용중인 채널 ID를 수집중입니다.') tvg_id_list = [] try: with open(channel_file) as f: for line in f: m = re.search(r'tvg-id="(\d+)"', line) if m is not None: tvg_id = str(m.groups()[0]) tvg_id_list.append(tvg_id) except IOError: print_error(channel_file + ' 파일을 읽을 수 없습니다.') sys.exit() return sorted(tvg_id_list, key=lambda x: int(x)) def print_log(*args): print(*args, file=sys.stderr) def print_error(*args): print("Error:", *args, file=sys.stderr) update_channel_enabled()
감사합니다
파이썬 2.7 버전은 무리없이 될 것으로 생각됩니다.
혹 실행이 안된다면 에러메시지를 올려주시면 수정해보겠습니다.
py 로 된 epg를 잘쓰다고 갑자기 업데이트하고 오류 터져서 지금은 php버전을 씁니다.<엄청 간단합니다.>
그리고 py 로 된걸 쓸려면 따롤 모듈을 따로 넣어주어야 되는데요 그게 또 버전이 안맞으면 안되드라구요..
이런쪽으로는 발걸음 수준인지라 좋은거 올려주서도 사용을 못하네요 ㄷㄷ
전버젼까지는 ISP만 바꾸면 됬는데...
외부호스팅 쓰다보니.. 속도에 크게 문제 없어서...
그냥 최대한 안만지는 것이 더 좋을수도 있을것 같아서요..
MyChannels "" 로 넣으면 그냥 ALL로 처리 된다던가...
아~ 찾았습니다... 채널.json에 enable하면 되것네요..
그런데.. 이것도 지우신다고요?
음....
그래도 안되면 에러 메시지를 캡쳐해서 보내주세요.