Skip to content

Commit 389321f

Browse files
committed
1.0.1 - new no-repeat mode added and bug fixes
1 parent 51f882f commit 389321f

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ Apart from those notes, things should work ok. Have fun, turn back the clock, an
7575
### -h/--help output
7676

7777
<pre>
78-
usage: teletext-twitter [-h] [-m MODE] [-q QUERY] [-c COUNT] [-d DELAY] [-v]
79-
[-Q]
78+
usage: teletext-twitter [-h] [-m MODE] [-q QUERY] [-c COUNT] [-d DELAY] [-n]
79+
[-v] [-Q]
8080

8181
Reads your Twitter timeline and turns it into teletext pages for your
8282
Raspberry Pi.
@@ -88,11 +88,12 @@ optional arguments:
8888
a search query, either a search term or a username.
8989
hashtags supported if you put quotes around the string
9090
-c COUNT, --count COUNT
91-
number of tweets to download (default is 5, maximum is
91+
number of tweets to download (default is 5, capped at
9292
200)
9393
-d DELAY, --delay DELAY
9494
seconds between timeline scrapes (default is 60
9595
seconds - lower values have no effect)
96+
-n, --no-repeat only download tweets once - overrules -d switch
9697
-v, --version show program's version number and exit
9798
-Q, --quiet suppresses all output to the terminal except warnings
9899
and errors

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Changelog
22

3+
### v1.0.1
4+
- added a new switch -n/--no-repeat which only downloads tweets once and exits
5+
- OK, *now* fasttext links have been suppressed
6+
- some old bugs crept back in. fixed
7+
38
### v1.0
49
- improved subpage counter in the header
510
- reduced max tweet download limit to 200 as the twitter API doesnt let you do anymore

teletext-twitter/__main__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def parse_args():
2525
parser.add_argument("-q", "--query", type=str, help="a search query, either a search term or a username. hashtags supported if you put quotes around the string")
2626
parser.add_argument("-c", "--count", type=int, default=5, help="number of tweets to download (default is 5, capped at 200)")
2727
parser.add_argument("-d", "--delay", type=int, default=60, help="seconds between timeline scrapes (default is 60 seconds - lower values have no effect)")
28-
parser.add_argument("-v", "--version", action="version", version="1.0")
28+
parser.add_argument("-n", "--no-repeat", action="store_true", default=False, help="only download tweets once - overrules -d switch")
29+
parser.add_argument("-v", "--version", action="version", version="1.0.1")
2930
parser.add_argument("-Q", "--quiet", action="store_true", default=False, help="suppresses all output to the terminal except warnings and errors")
3031

3132
args = parser.parse_args()
@@ -43,6 +44,7 @@ def parse_args():
4344

4445
def main():
4546
args = parse_args()
47+
print(args)
4648

4749
if not args.quiet:
4850
print("[*] teletext-twitter - (c) 2018 Mark Pentler (https://github.com/mpentler)", file=sys.stdout)
@@ -75,7 +77,12 @@ def main():
7577
sys.exit(1)
7678
print("[!] Error accessing your Twitter timeline: {}".format(error['message']), file=sys.stderr)
7779
print("[!] Trying again after specified delay", file=sys.stderr)
78-
time.sleep(args.delay)
80+
if not args.no_repeat:
81+
time.sleep(args.delay)
82+
else:
83+
if not args.quiet:
84+
print("[*] No repeat mode enabled. Exiting...", file=sys.stdout)
85+
sys.exit(1)
7986

8087
if __name__ == '__main__':
8188
try:

teletext-twitter/output.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ def write_tweets(twitter_object, mode, count, config, query=None): # grab the la
8383
tweet_text = charsub(tweet_text)
8484
tweet_text = textwrap.wrap(tweet_text, 38) # make sure our lines fit on the screen
8585
tweet_time = time.strptime(status.created_at,"%a %b %d %H:%M:%S +0000 %Y")
86-
tweet_human_time = time.strftime("%d-%b-%Y %H:%M", tweet_time) # reformat time/date output
86+
tweet_human_time = time.strftime("%d-%b-%Y %H:%S", tweet_time) # reformat time/date output
8787
tweet_username = charsub(status.user.screen_name)
8888

8989
with open(filename, "a") as file:
9090
post_length = len(tweet_text) + 1 # how long is our next tweet? (including info line)
9191
if (line_position + post_length) > 25: # are we about to go over the page?
9292
for blankline_position in range(line_position, 25): # how many blank lines do we need?
93-
file.write("OL,{},\r\n".format(blankline_position))
93+
file.write("OL,{},".format(blankline_position) + (" " * 15) + "\r\n")
94+
file.write("FL,0,0,0,0,0,100\r\n")
9495
subpage += 1 # start a new page
9596
if subpage > 99:
9697
break # reached subpage limit - dump the rest

0 commit comments

Comments
 (0)