DEV Community

Cover image for STAR ASCIIMATION WARS
Mustafa Unal
Mustafa Unal

Posted on

STAR ASCIIMATION WARS

Overview of My Submission

Would you like yo watch Star Wars from MongoDB using nothing but mongo shell ? You are in good hands. The wonderful work done by Simon Jansen in https://asciimation.co.nz/ has been ported to MongoDB in full glory. You need nothing but a MongoDB and mongo shell.

Submission Category:

Choose Your Own Adventure

Link to Code

GitHub logo bleakview / mongosaw

Star Ascii Wars MongoDB Edition

mongosaw

Star Ascii Wars MongoDB Edition




Additional Resources / Info

Trailer:

I use starasciiwars database but you can select your own.
For trailer you only need the github repo to watch the entire movie. Open https://asciimation.co.nz/ in chrome

Press F12 to open developer console and paste the following code into console to download movie as a txt file.

var temp = document.createElement('a');
temp.href = URL.createObjectURL(new Blob([film.join('\n')], { type: 'text/plain' }));
temp.download = 'starwars.txt';
temp.click();
Enter fullscreen mode Exit fullscreen mode

Use the following command to convert txt to json file.

ascii2jsonmovie.py
Enter fullscreen mode Exit fullscreen mode

Use the following command to import json file to DB

mongoimport --uri <your mongodb uri> --db starasciiwars --collection trailer --drop --jsonArray --type json --maintainInsertionOrder --username=<user name>  --file starwars.json
Enter fullscreen mode Exit fullscreen mode

Use the following command for mongoshell to connect to MongoDB.

mongosh <your mongodb uri> --username=<user name>
Enter fullscreen mode Exit fullscreen mode

Select starasciiwars database

use starasciiwars
Enter fullscreen mode Exit fullscreen mode

Run the following command to watch the movie. you can use speedX variable to set the speed.

db.episodeIV.find().sort({_id:1}).forEach(function(frame){
cls();
speedX=1;
print(frame.line1);
print(frame.line2);
print(frame.line3);
print(frame.line4);
print(frame.line5);
print(frame.line6);
print(frame.line7);
print(frame.line8);
print(frame.line9);
print(frame.line10);
print(frame.line11);
print(frame.line12);
print(frame.line13);
sleep(frame.sleeptime*120*speedX);
});
Enter fullscreen mode Exit fullscreen mode

Thanks to https://github.com/JLChnToZ for offline download

Top comments (0)