Skip to main content

Star Wars ASCIImation with Python - Windows

In this post, we'll watch a Star Wars movie in ASCII format.
The only thing we need for this demo is Python-installed PC and internet connection.

Figure: Screenshots from Python Command line while Star Wars is being streamed


All credits gained in this demo will go to "blinkenlights.nl" [2] website, which broadcasts this ASCII movie using Telnet protocol on Port 23, and Python which makes socket implementation very easy for us. No authentication is needed for this broadcast.

Anyone who is able to create a TCP socket and listens blinkenlights.nl on port 23 would be able to get this stream and display on their Python command line.


CODE

My main source for Python source code is [1].

What  code below does is simply importing Python "socket" library, create a socket, use "towel.blinkenlights.nl" address variable to create connection, receive data from socket and display it. While typing (copy/paste) code, be careful about indentation. Don't forget that Python is sensitive about indentation since it interprets tab characters as function blocks (parenthesis and curly brackets in C-style languages)

Note that main body of the code is within an infinite loop. If you want to interrupt/stop streaming, use "Ctrl + C" key combination.


import socket
addr_info = socket.getaddrinfo("towel.blinkenlights.nl", 23)
addr = addr_info[0][-1]
s = socket.socket()
s.connect(addr)
while True:
 data = s.recv(500)
 print(str(data, 'utf8'), end='')



Figure: Code required for ASCIImation of Star Wars


TEST ENVIRONMENT
PC: Windows 10, 64-bit
Python Version: 3.6
REFERENCES
[1] https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/network_tcp.html#star-wars-asciimation [2] http://blinkenlights.nl/

Comments

Popular posts from this blog

Xcode vs Visual Studio - Mostly Used Feature Comparison

In this post, I will try demonstrate mostly used menus and functions of the most famous two Integrated Development Environments (IDE) of Microsoft and Apple... namely Visual Studio and Xcode respectively. Versions of the IDEs used in this post is Microsoft Visual Studio 2015 and Xcode 8.2.1. What you will find here is mostly used features like Auto Indent, Comment out, Uncomment, Debugging shortcuts, Attaching to a process etc. in a comparative manner. In other words, these features are demonstrated by using both Xcode and Visual Studio one by one. If you have already been using one of these IDEs, you will switch and adapt to the other IDE easily thanks to this article. 1- Auto Indent Xcode: Select the text Right click on the selected text Click on " Structure -> Re-Indent ". (Control + I) VS: Select the text Click on " Edit -> Advanced -> Format Selection " If you want to Auto-Indent all document (not only small por...

How to Trust An Apllication in iOS installed outside of AppStore?

If you installed application on your iPhone outside of AppStore, you will not be allowed to open that application unless you tell iOS that you trust on the developer of this application. When you try to open an untrusted app, you will get the following error message.                                                         So, how can one tell iOS that developer of an application is trusted or not? 1- Tap on " Settings " app. 2- Tap on " General ".                                                       3- Tap on " Device Management ". 4- Now, you will here see the list of all applications whose developers are untrusted. In my example, name of the application which was installed ou...