瀏覽代碼

Add main function + command line option to run once (#19)

pull/20/head
Georg Krause GitHub 4 年之前
父節點
當前提交
187d12f10c
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 22 次插入1 次删除
  1. +22
    -1
      youtube2peertube.py

+ 22
- 1
youtube2peertube.py 查看文件

@@ -1,5 +1,7 @@
#!/usr/bin/python3

import sys
import getopt
import pafy
import feedparser as fp
from urllib.request import urlretrieve
@@ -322,5 +324,24 @@ def run(run_once=True):
run_steps(conf)
sleep(poll_frequency)


def main(argv):
run_once=False
try:
opts, args = getopt.getopt(argv,"ho",["help","once"])
except:
print("youtube2peertube.py [-o|--once]")
sys(exit(2))

for opt, arg in opts:
if opt == '-h':
print("youtube2peertube.py [-o|--once]")
sys.exit()
elif opt in ("-o", "--once"):
run_once = True

run(run_once)


if __name__ == "__main__":
run(run_once=False)
main(sys.argv[1:])

Loading…
取消
儲存