I recently switched from iOS to Android, and one of the apps I had used on iOS was the mobile Livestream app. One feature was the ability to follow channels, and I liked to follow channels to see how some of my favorite artists draw--techniques and whatnot. (Also some other random channels whose content I might enjoy).
So anyway, I lost the ability to do this, since I couldn't find an equivalent app on Android. Apparently on the PC, one could make a "New Livestream" account to follow, but I don't wanna.
Solution? Make some code!
My computer-science-major friend had once told me about Python, a pretty (really) versatile scripting language. What better way to learn about this awesome language?
My code follows:
#checks if livestream is live
#read some files
read = open('livestream channels.txt','r')
str1 = read.read().split()
read = open('justin-twitch channels.txt','r')
str2 = read.read().split()
#create a 2D array| columns:3, rows:number of streams
info = [['' for j in range(3)] for i in range(len(str1+str2))]
#info = [['']*3]*len(str1) |doesnt work|
#get the channel information
for i in range(len(str1)):
#get and parse json
url3 = urllib2.urlopen('http://x%sx.api.channel.livestream.com/2.0/livestatus.json' % str1[i]).read()
asd = json.loads(url3)
info[i] = str1[i] #save stream name
info[i] = asd['channel']['currentViewerCount'] #save stream viewer count
if asd['channel']['isLive']: #if live
#mark as live
info[i] = 1
info[i] = 0
for i in range(len(str2)):
url3 = urllib2.urlopen('http://api.justin.tv/api/stream/list.json?channel=%s' % str2[i]).read()
asd = json.loads(url3)
info[i+len(str1)] = str2[i] #save stream name
if asd: #if live
info[i+len(str1)] = 1 #mark as live
info[i+len(str1)] = asd['channel_count'] #save stream viewer count
info[i+len(str1)] = 0
Enter the number to view the stream.
for i in range(len(info)):
print (str(i+1).rjust(5)+': %s %s \t%s' % ('*' if info[i] else ' ', info[i], info[i]))
option = 1
while option != 0:
option = input('Enter the number: ')
if option == 0: #just exit
elif option in range(len(str1)+1): #livestream from 1 to n
elif option in range(len(str1)+1, len(str1)+1+len(str2)): #justin.tv from n to last
print ('Invalid choice. Please choose a correct one.')
And there it is!
txt files named "livestream channels.txt" and "justin-twitch channels.txt" should have the channel names of the appropriate streaming service, separated by new lines. They exist in the same folder as the python script.