45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
# Sermon Upload v1.0
|
|
|
|
from subprocess import call # We can do BASH in Python if needed.
|
|
import os # Lots of system stuff
|
|
from shutil import copyfile # Allow copying of files
|
|
import glob # Import glob tools for file listings.
|
|
import notify2 # Notification utility.
|
|
import time # Import time into the galaxy
|
|
|
|
time.sleep(10) # Wait 10 seconds.
|
|
os.chdir("/mnt/52265C99265C8041/Users/Berean-Sound/sermons") #
|
|
list = sorted(glob.glob('*.mp3'))
|
|
mostrecent = list[-1]
|
|
secondrecent = list[-2]
|
|
|
|
sermonsrc = "/mnt/52265C99265C8041/Users/Berean-Sound/sermons/" + mostrecent
|
|
sermondst = "/home/berean/sermons/2018/" + mostrecent # /home/berean/sermons/2018/
|
|
|
|
copyfile(sermonsrc, sermondst)
|
|
|
|
os.chdir("/home/berean/sermons/2018/")
|
|
os.system("rsync --update --progress -e 'ssh -i /home/berean/sermons/.tempssh/temp' *.mp3 sermons@bereanbibleutah.org:/home/josh/sermons/2018/")
|
|
|
|
#call(sermons=$("ssh -i /home/berean/sermons/.tempssh/temp sermons@bereanbibleutah.org 'ls /home/josh/sermons/2018'")
|
|
#recentsermon = call("$(echo hi)")
|
|
#recentsermon = call("echo $sermons")
|
|
#print(recentsermon)
|
|
|
|
# if mostrecent == recentsermon:
|
|
#
|
|
notify2.init('Sermon Script')
|
|
n = notify2.Notification("Sermon Uploaded", # NOTE TO SELF: Add validation.
|
|
mostrecent #(var + " and " + secondrecent) #,
|
|
# "notification-message-im" # Icon name
|
|
)
|
|
n.show()
|
|
|
|
# else:
|
|
# notify2.init('Sermon Script')
|
|
# n = notify2.Notification("Sermon Upload Failed",
|
|
# mostrecent #(var + " and " + secondrecent) #,
|
|
# # "notification-message-im" # Icon name
|
|
# )
|
|
# n.show()
|