daniel-widrick / zap2it-GuideScraping

MIT License
61 stars 22 forks source link

Config file example? #26

Closed JDiaz11 closed 1 year ago

JDiaz11 commented 1 year ago

Am I an idiot or why can I not intuitively figure out how to create a properly formatted config file? Is there a sample I can review somewhere please? I really do not understand what is supposed to go into it. From reading the python file (which was the only way I even determined that the file would need to be named "zap2itconfig.ini") and a bit of research on properly formatting an ini file, I managed to piece together the following, which raises a "HTTP Error 401: Unauthorized" error. So at least I got beyond the MissingSectionHeaderError and NoSectionError. But a little guidance would be wonderful, please.


 [url]
 "https://tvlistings.zap2it.com/api/printGrid?lineupId=...etc
 [creds]
 emailid=email@email.com
 username=my_username
 password=my_password
 [prefs]
 country=USA
 zipCode=00000
 lang=en-us
dustyoldbonez commented 1 year ago

It took me awhile to figure out but here's what I had to do to get it working. Keep in mind I have no idea what I'm doing so there may be some unnecessary or redundant steps, but at least its working.

  1. Download the zap2it-GuideScrapering release and export the contents of the .zip to a permanent location
  2. Create an account on zap2it.com
  3. Enter your zap2it credentials into the "zap2itconfig.ini.dist" file, update with your local zip code
  4. Log into zap2it.com and go to the "TV Listings" page then click the print button
  5. Get get "headendId" from the URL in the address bar and paste that into the "headendId:" and "lineupId: " fields in the "zap2itconfig.ini.dist" file
  6. Make a copy of the "zap2itconfig.ini.dist" file and rename it "zap2itconfig.ini"
  7. Install the latest version of Python
  8. Update the system PATH variable to point to python.exe, mine was in my appdata/local folder
  9. Edit the following command to point to your zap2it folder and run it from command prompt: python "G:\Data\zap2it-GuideScrape.py" -c "G:\Data\zap2itconfig.ini" -o "G:\Data\xmlguide.xmltv"
dustyoldbonez commented 1 year ago

It saves 14 days of data but if you're on Windows and would like it to update daily you can do this with Task Scheduler.

  1. Create a new text document in your zap2it folder and name it "update.bat"
  2. Paste your edited command in, example: python "G:\Data\zap2it-GuideScrape.py" -c "G:\Data\zap2itconfig.ini" -o "G:\Data\xmlguide.xmltv", and save the file
  3. Open Task Scheduler and Create Basic Task
  4. Name, "TV Guide Update", Next >, "Daily", Next >
  5. Set a time, Next >, "Start a program", Next >, Browse to your .bat file, Next >
  6. Select "Open the Properties dialog for the task when I click Finish", Finish
  7. Select "Hidden", Configure for "Windows 10" or whatever you're using, OK

The script creates a backup of each query in addition to the "xmlguide.xmltv" file which gets overwritten so roughly 250MB of files are created each week. You will need to edit def CopyHistorical(self): out of the script or manually delete these copies on a regular basis.

daniel-widrick commented 1 year ago

As mentioned by @dustyoldbonez there is an included config.ini.dist available in the repository that has all fields and example values for each field. The software relies on a personal zap2it.com account and you will need to sign up for an account and provide credentials in the config file for such an account.