WisconsinEric

EPG from XMLTVListings

Recommended Posts

9 minutes ago, WisconsinEric said:

Grrrrr . . . .

So am I good? If I quit Terminal, will it remember instructions so far? You are dealing with a command line phobe.

Share this post


Link to post
Share on other sites
2 hours ago, Earl Noe said:

So am I good? If I quit Terminal, will it remember instructions so far? You are dealing with a command line phobe.

Presumably. How to tell: run the program (I gather you did). Look at the Program Guide in EyeTV and see if it extends out 14 days (if you chose that length in Step 1 in the Guide I posted).

I gather you haven't done Step 2 yet to automate it so you never have to touch it again. If you want to put that off but still avoid that Terminal command, go instead to Step 3 and do the one line of code that UnixGuy posted (I included it as Step 3). When you have that done that step, and restart EyeTV, you should then see a new menu with the Applescript logo and one option, whatever you called the command when you typed it. Anytime you are in EyeTV just click on that and it will run the program you created in Step 1 and update the Program Guide. Saves going to Terminal. Important: never do this while recording something, apparently it will kill the recording.

Share this post


Link to post
Share on other sites

^Another way to tell if your (daily) EPG update worked: go to your account on the XMLTVListings web site. Note the entry "Today's Downloads" under "Your Lineups." It resets to 0/5 daily at midnight eastern time (XML is in Ottawa, Ontario). So if it says 1/5 after you run your update manually, you're good. I have my EPG update automated for 5 am; for the first few days after implementing that I wanted to check it from my laptop computer without firing up the big media center TV. Each morning my account said 1/5 and after doing that for a few days I concluded everything was working as it was supposed to and forgot about it.

Share this post


Link to post
Share on other sites
On 3/15/2019 at 10:47 PM, WisconsinEric said:

Anyway, keep at it, I know it works (it has for me for a month now without a single problem), and I'll keep my notification turned out for further developments.

I thought my flailing had been revealed to be a simple typo, but no. I seem to be right back where I started.  Here is a shot of my program file nestling innocently in Scripts in my home directory.

screenshot_353.jpg.cc0e85ae6a87c8f07d8f32fb765c6588.jpg

If I name it just getepg, I get the following in Terminal:

Last login: Sun Mar 24 00:40:35 on ttys000

macmini:~ earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg

chmod: getepg: No such file or directory

macmini:Scripts earlnoe$ 

If I name it getepg.txt, either just by changing the filename or using the Getinfo window, the chmod command is accepted, but

 

macmini:Scripts earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg.txt

macmini:Scripts earlnoe$ ./getepg.txt

cd: bad interpreter: No such file or directory

macmini:Scripts earlnoe$ ./getepg

-bash: ./getepg: No such file or directory

macmini:Scripts earlnoe$ 

[sound of thinning grey hair being pulled out]

Incidentally, I found that if I paste the line of code:

www.xmltvlistings.com/xmltv/get/MY KEY/4105/14 > xmltv.xml

into Chrome with my API key in the right place, I can download a file 14 _ xmltv.xml. When loaded into EyeTV, though, it only updates 7 (actually 6.5) days, not 14.

Is it my bad karma?

Share this post


Link to post
Share on other sites

^ Change the filename of getepg.txt to getepg AFTER making it an executable. Make sure the program was prepared in TextEdit AFTER turning off rich text and writing it as a plain text only. See if that works. As for updates, xmltv updates daily at midnight GMT (it took me a bit to figure that out). So here in Wisconsin listings go to 6 pm on the 14th day.

Share this post


Link to post
Share on other sites
3 hours ago, WisconsinEric said:

Make sure the program was prepared in TextEdit AFTER turning off rich text and writing it as a plain text only.

Yes, it's definitely plain text. Does the text encoding matter? Default seems to be Unicode (UTF-8).

In this session, right after the chmod command, I hid the .txt extension, changing file name to getepg

Last login: Sun Mar 24 10:38:00 on ttys000

macmini:~ earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg.txt

macmini:Scripts earlnoe$ ./getepg

-bash: ./getepg: No such file or directory

macmini:Scripts earlnoe$ 

Share this post


Link to post
Share on other sites
9 minutes ago, Earl Noe said:

Yes, it's definitely plain text. Does the text encoding matter?

Default seems to be Unicode (UTF-8).

In this session, right after the chmod command, I hid the .txt extension, changing file name to getepg

Last login: Sun Mar 24 10:38:00 on ttys000

macmini:~ earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg.txt

macmini:Scripts earlnoe$ ./getepg

-bash: ./getepg: No such file or directory

macmini:Scripts earlnoe$ 

Based on my trial and error, the text encoding makes the difference between it working and more missing hair. The reason the above didn't work is that getepg is a different file from getepg.txt. Starting from the beginning:

* In TextEdit preferences, click "Plain Text" as the setting for a new document (which will be getepg). Then open a new document and type your commands.

* When saving, make sure the box "If no extension is provided, use ".txt" " is NOT checked. The resulting file should have no listed file type when you do Get Info (Kind will = TextEdit Document) and in the GUI (no .filetype shown in the file name, and the file icon will be blank).

* Then proceed with moving it into your Scripts folder, making it an executable, and it should work.

Share this post


Link to post
Share on other sites
6 minutes ago, WisconsinEric said:

* Then proceed with moving it into your Scripts folder, making it an executable, and it should work.

OK. Followed that carefully. The chmod command worked, but

macmini:Scripts earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg

macmini:Scripts earlnoe$ ./getepg

cd: bad interpreter: No such file or directory

macmini:Scripts earlnoe$ 

I found out by experiment that the Finder treats getepg and getpg.txt as the same file. It won't let me save both into the same folder. Before the session above, I threw the contents of Scripts away, saved a fresh copy to the Desktop as getepg with the extension checkbox unchecked, and dragged it into Scripts.

 

 

Share this post


Link to post
Share on other sites
1 hour ago, Earl Noe said:

macmini:Scripts earlnoe$ ./getepg

cd: bad interpreter: No such file or directory

 

It sounds as though it is the contents of getepg that is now bad.  Is there perhaps a cd command in the getepg file?

Share this post


Link to post
Share on other sites
2 hours ago, UnixGuy said:

It sounds as though it is the contents of getepg that is now bad.  Is there perhaps a cd command in the getepg file?

Here is the template I used for getepg from the Guide. I inserted my username, API key and lineup number in the bracketed spots:

 #!/bin/bash

cd /Users/[yourusername] /Scripts/

curl https://www.xmltvlistings.com/xmltv/get/[your API key] /[your lineup ID] /14  > xmltv.xml

#pause 30 seconds as cushion for download to complete

sleep 30s

#load EPG into EyeTV

open -a EyeTV xmltv.xml

Share this post


Link to post
Share on other sites

https://stackoverflow.com/questions/2841593/bash-script-bad-interpreter

There is a similar error discussed at the above link.

From that discussion, it appears likely that you first created the script using a Microsoft text editor, and then cut and pasted the result into the TextEdit window.  The problem with that approach is that the MS Office software puts all kinds of invisible funny characters into their documents.  In particular, Microsoft uses a CR/LF combination where the Mac just uses a CR.  (And Linux uses just a LF.).

Instead of cut-and-paste, try manually typing each of the characters into the TextEdit window.  As Wisconsin Eric mentioned, plain text is essential.  You never know what invisible characters might be lurking in a document!

Share this post


Link to post
Share on other sites
4 minutes ago, UnixGuy said:

You never know what invisible characters might be lurking in a document!

I'll try keyboarding it into Textedit. What I did was copy from the PDF version of the Guide and paste into Textedit.

Share this post


Link to post
Share on other sites

^ Ah, you didn't mention that before. Reinforcing what UnixGuy said, there seem to be invisible formatting characters in many (all?) non-text software. I found by trial and error that copying and pasting always resulted in failure; it had to be typed in using plain text and saved that way with no file type. Give it a try that way, we're rootin' for you! These errors are always little hand-on-the-forehead things, and based on my own sad experience I suggest that you see a good chiropractor after you get done kicking yourself. 😉

Share this post


Link to post
Share on other sites
25 minutes ago, Earl Noe said:

'll try keyboarding it into Textedit.

I got the following result in Terminal and an xml file appeared in Scripts, though the xmltv Dashboard shows 0 downloads. I can't find a typo in the URL:

Last login: Sun Mar 24 21:37:36 on ttys000

macmini:~ earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg

macmini:Scripts earlnoe$ ./getepg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: https

curl: (3) <url> malformed

macmini:Scripts earlnoe$ 

 

Share this post


Link to post
Share on other sites

^ This clearly means you didn't connect (2 pieces of evidence - "could not resolve" which probably means the URL is wrong, and downloads = 0 which means you did not connect and nothing was downloaded. 10 to 1 that .xml file you have is empty. If you could copy and paste the contents of the "getepg" file here we can take a look at it. At this point that seems to be where the problem lies. [I have to be away from the computer for over an hour now, will check later]

Share this post


Link to post
Share on other sites
7 minutes ago, WisconsinEric said:

10 to 1 that .xml file you have is empty.

Yup. The xml file is mt. Here's a cut 'n' paste of getepg from Textedit, with a placeholder for my API key, which I probably shouldn't post here, yes? Thank you for being so patient:

#!/bin/bash
cd /Users/earlnoe/Scripts/
curl https:/ /www.xmltvlistings.com/xmltv/get/MYAPI/4105/14>xmltv.xml
#pause 30 seconds as cushion for download to complete
sleep 30s
#load EPG into EyeTV
open -a EyeTV xmltv.xml

 

Edited by Earl Noe

Share this post


Link to post
Share on other sites

curl https:/ /www.xmltvlistings.com/xmltv/get/MYAPI/4105/14>xmltv.xml

You need a space between 14 and > and also a space after the > So . . .

curl https:/ /www.xmltvlistings.com/xmltv/get/MYAPI/4105/14 > xmltv.xml

Edited by WisconsinEric
  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, WisconsinEric said:

You need a space between 14 and > and also a space after the > So . . .

I opened getepg in Textedit, added the spaces, saved, but:

Last login: Sun Mar 24 22:08:06 on ttys000

macmini:~ earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg

macmini:Scripts earlnoe$ ./getepg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: https

curl: (3) <url> malformed

Share this post


Link to post
Share on other sites

It often happens to me that I think I saved a change but actually didn't.  Or I copied the original file from a different place, but I forget to copy the changed file, or something else like that.  Do 

macmini:Scripts earlnoe$ cat getepg

which prints the file getepg, just before

macmini:Scripts earlnoe$ ./getepg

which executes it, to make sure you are executing with the change.

Share this post


Link to post
Share on other sites
6 minutes ago, UnixGuy said:

 Do 

macmini:Scripts earlnoe$ cat getepg

 

I need to wait a few minutes until EyeTV finishes a recording. I'm pretty sure the spaces are there because when I open getepg in Textedit and move the cursor through the URL with the arrow key, it shows a space on either side of the >. I have wondered if that space between the two forward slashes after https: is right.

Share this post


Link to post
Share on other sites
22 minutes ago, Earl Noe said:

 I have wondered if that space between the two forward slashes after https: is right.

Good catch!!   You are correct, there should NOT be a space between the forward slashes.

Share this post


Link to post
Share on other sites
8 minutes ago, UnixGuy said:

Good catch!!   You are correct, there should NOT be a space between the forward slashes.

BINGO! The space is definitely there in the PDF, as revealed by the arrow key, but it didn't seem like the usual convention for URLs. Removing it in Textedit and resaving allowed the following result in Terminal. Is it correct to use the chmod command after making a change to getepg?

Last login: Mon Mar 25 00:04:59 on ttys000

macmini:~ earlnoe$ cd /Users/earlnoe/Scripts/

macmini:Scripts earlnoe$ chmod 755 getepg

macmini:Scripts earlnoe$ ./getepg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 17.7M    0 17.7M    0     0   483k      0 --:--:--  0:00:37 --:--:--  633k

macmini:Scripts earlnoe$ 

the xml file that appeared in Scripts is not empty, Dashboard shows 1 download, and the EyeTV schedule has been extended. I really appreciate the help from both of you. I hope I can complete the rest of the process with less pain and requiring less coaching, without which I would have given up in frustration.

Share this post


Link to post
Share on other sites

Good luck with your updating!  Thanks for myself also to WisconsinErik for researching this workaround.

It is not necessary to keep CHMOD'ing the file.  After it is done once, it sticks.  You can do

macmini:~ earlnoe$ ls -l getepg

to see what the permissions are.  The listing should look something like this:

-rwxr-xr-x  1 earlnoe  staff  130 Mar  4 18:56 getepg

where the x indicates execute permission (rwx = read, write, execute).
 

Share this post


Link to post
Share on other sites

^ And thanks to both of YOU, since I actually used material from your posts in what I wrote up. 😀 This was a group effort that produced good results.  Now . . . on to the remaining steps. You could do Step #3 (the easy one) first, since there is just one line of code; that will put an AppleScript menu in EyeTV with just one option, to run the program to update the EPG (which you just got running) with a single click from within EyeTV instead of having to type it into Terminal each time. Just 2 cautions: #1 - it appears to freeze EyeTV while it is running (it will unfreeze when it finishes), so do NOT run it while recording; #2 - if you have a lot of channels, it may take up to a couple of minutes to finish, it hasn't frozen, just be patient. And remember that XMLTVListings.com has a limit of 5 downloads a day (it resets at midnight GMT).

Step #2 will end your typing forever, so this time start with a plain text file in TextEdit and user your cursor to get the spaces right  (the eye is just not accurate at picking them up!). Good luck.

Share this post


Link to post
Share on other sites

Not sure if it's helpful or not (too late for Earl, no doubt), but attached are text files of the GetEPG script and the PLIST file. Unsure if anything strange will happen to them between my uploading and them being downloaded.

Note that I switched out my info with generic placeholders, so hopefully I didn't screw anything up in the process. 

Swap out YOURUSERNAME, YOURAPIKEY and YOURLINEUP.  You have to change YOURUSERNAME in the file name of the PLIST file as well.

Attached is a zip archive with the 2 files and also each file separately uncompressed.

GetEPG com.YOURUSERNAME.GetEPG.plist GetEPG.zip

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.