1
1
mirror of https://github.com/mister-monster/YouTube2PeerTube.git synced 2024-11-21 19:44:17 -05:00

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

This commit is contained in:
Georg Krause 2020-05-24 08:40:05 +02:00 committed by GitHub
parent fbc28562a5
commit 187d12f10c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys
import getopt
import pafy import pafy
import feedparser as fp import feedparser as fp
from urllib.request import urlretrieve from urllib.request import urlretrieve
@ -322,5 +324,24 @@ def run(run_once=True):
run_steps(conf) run_steps(conf)
sleep(poll_frequency) 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__": if __name__ == "__main__":
run(run_once=False) main(sys.argv[1:])