Skip to content

Commit

Permalink
added page_number to config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mpentler committed Feb 7, 2018
1 parent 5f577b4 commit 5678b7f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Before you get this up and running there are two other things you need to do fir
After getting these up and running there are some setup tasks to do. Rename config.py-default to config.py and open the file in a text editor. You need to add:

1) Your Twitter access tokens: You can find a good guide for doing this here - https://iag.me/socialmedia/how-to-create-a-twitter-app-in-8-easy-steps/ You will need to pick a unique name for the app. Which is annoying. Pick anything you want that isn't taken. Maybe add your name at the end.
2) Check where your pages will be saved to: Change the tti_path line too if you've changed your Teefax location.
2) Check where your pages will be saved to: Change the tti_path line too if you've changed your Teefax location. You can also customise the page number.
3) Change the colours if you want: Theme support is detailed below

When you've setup your config.py you can run the script like this example that grabs your home timeline:

`python3 teletext-twitter -t` (add -h to show options - also listed below)

The script will constantly update a spare page (153 - chosen because it used to be used for this purpose on Teefax in the past) in the main teletext folder (which defaults in VBIT2 to /home/pi/teletext/).
The script will constantly update your chosen page number (default is 153 - chosen because it used to be used for this purpose on Teefax in the past) in the main teletext folder (which defaults in VBIT2 to /home/pi/teletext/).

All of the files in that folder are sent across to the TV every so often, therefore the script constantly overwrites it with new tweets (up to 5 - space permitting!) so that it will update on your screen.

Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

### v0.5.3
- Page number now user-customisable

### v0.5.2
- Fixed stupid bug where I'd used %S instead of %M for the time display. now they're correct

Expand Down
1 change: 1 addition & 0 deletions config.py-default
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ timestamp_colour = "yellow"

# miscellaneous
tti_path = "/home/pi/teletext/"
page_number = 153
8 changes: 4 additions & 4 deletions teletext-twitter/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def write_tweet_line(file, line_num, line, config):
def write_header(config): # write a header for the page and pop a nice banner at the top
page_title = config["page_title"]
logo_spacer = " " * (39 - (4 + len(page_title) + 5))
with open(config["tti_path"] + "P153.tti", "w+") as file:
with open(config["tti_path"] + "P" + str(config["page_number"]) + ".tti", "w+") as file:
file.write("DE,Autogenerated by Teletext-Twitter\r\n")
file.write("PN,15300\r\n")
file.write("PN," + str(config["page_number"]) + "00\r\n")
file.write("SC,0000\r\n")
file.write("PS,8000\r\n")
file.write("OL,1," + ESCAPE + chr(text_colours[config["header_colour"]]) + SET_BACKGROUND +
Expand All @@ -56,7 +56,7 @@ def write_timeline(twitter_object, config): # grab the latest timeline - only 5
if (line_position + len(tweet_text) + 1) > 24: # are we going to fill the page?
break # yep! dump the last tweet!

with open(config["tti_path"] + "P153.tti", "a") as file:
with open(config["tti_path"] + "P" + str(config["page_number"]) + ".tti", "a") as file:
write_tweet_info(file, line_position, tweet_username, tweet_human_time, config)
line_position += 1
for line in tweet_text:
Expand All @@ -77,7 +77,7 @@ def write_search_term(twitter_object, search_term, config): # search recent twee
if (line_position + len(tweet_text) + 1) > 24: # are we going to fill the page?
break # yep! dump the last tweet!

with open(config["tti_path"] + "P153.tti", "a") as file:
with open(config["tti_path"] + "P" + str(config["page_number"]) + ".tti", "a") as file:
write_tweet_info(file, line_position, tweet_username, tweet_human_time, config)
line_position += 1
for line in tweet_text:
Expand Down

0 comments on commit 5678b7f

Please sign in to comment.