Skip to content

Commit

Permalink
Keep historical guide data. TODO: cleanup?
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-widrick committed Apr 26, 2021
1 parent 310c7c5 commit 6067e91
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion zap2it-GuideScrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import html
#Additional Libraries for Parameter Parsing
import sys, getopt
#Libraries for historical copies
import datetime

def sanitizeData(data):
#https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
Expand Down Expand Up @@ -103,7 +105,7 @@ def buildXMLDate(inputDateString):
elif opt in ("-i","--ifile"):
optConfigFile = arg
elif opt in ("-o","--ofile"):
outGuideFile = arg
optGuideFile = arg
print("Loading config: ", optConfigFile, " and outputting: ", optGuideFile)


Expand Down Expand Up @@ -199,3 +201,13 @@ def buildXMLDate(inputDateString):
file = open(optGuideFile,"wb")
file.write(guideXML.encode('utf8'))
file.close()

#Write a Copy of the file with the current timestamp
dateTimeObj = datetime.datetime.now()
timestampStr = "." + dateTimeObj.strftime("%Y%m%d%H%M%s") + '.xmltv'
histGuideFile = timestampStr.join(optGuideFile.rsplit('.xmltv',1))
file = open(histGuideFile,"wb")
file.write(guideXML.encode('utf8'))
file.close()

#TODO Clean old files?

1 comment on commit 6067e91

@daniel-widrick
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implements suggestion 3 from #7

Please sign in to comment.