Skip to content

Commit

Permalink
Scrape descriptions and write them to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
jbranchaud committed Nov 1, 2018
1 parent 5bb2efb commit 5455037
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 3 deletions.
42 changes: 42 additions & 0 deletions episode-descriptions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

Rick, in a drunken state, takes his grandson, Morty, for a ride in his flying car and rambles on about how he plans to use a neutrino bomb to wipe out all life on Earth. Rick lands the vehicle on Morty's demand and passes out. The bomb activates by itself and seems to be left unchecked, but ultimately it is shown that life on Earth remains intact. After having breakfast with their family, Rick takes Morty to another dimension to collect seeds of "Mega Trees", which Morty is forced to hide in his own rectum to get past intergalactic customs. However, Rick and Morty's cover is blown and they escape while engaging in a shootout with alien insects. Ultimately, the seeds briefly cause Morty to be highly intelligent, despite the fact that he missed a semester of school because he's been in adventures with Rick. This causes his parents to believe he is fine with his education, but this wastes the seeds, so Rick informs Morty that they need to go back and get more, while their aftereffects leave Morty writhing on the floor.
On Jerry's demand, Rick gives Snuffles, the family dog, an intelligence-enhancing helmet. Rick and Morty, in an Inception-esque scenario, enter the dream of Morty's teacher, in an attempt to make him give Morty an "A" in math class. They find themselves in a dangerous situation, where they are forced to repeatedly enter dreams within dreams to escape. Eventually, they are chased by a dream character named Scary Terry, a parody of Freddy Krueger. They manage to enter his dream, where they stand up for him against his bully teacher. This persuades Scary Terry to help them complete their mission. Meanwhile, at home, Snuffles builds a mechanical suit and assembles a dog army intending to take over Earth. Returning home from their adventure, Rick and Morty enter Snuffles' dream, where Rick causes Morty to fall into a coma. This prompts Snuffles to rethink his priorities, resulting in him taking his army to another planet.


Post-credit scene: Back in Scary Terry's class, the old teacher has been replaced by Scary Glenn, a hippie drum player. Rick and Scary Terry are sitting as his students, smoking marijuana, satisfied with this change.
On Christmas, Rick sends Morty inside the body of a homeless man to save his life (a parody of Fantastic Voyage). Inside the man's body is a microscopic enclosure called Anatomy Park (a parody of Jurassic Park), which houses various deadly diseases that escape their enclosures. Back at the family home, Jerry's parents visit, and the family attempts to bond without electronic devices.


Post-credit scene: Rick contacts Annie and her other new associates inside his new patient's body and as they talk about his "Pirates of the Pancreas" ride (much to Rick's dislike, since he is sensitive about his ride because it's his idea). Rick hangs up on them only to proceed with a rant and insults, also revealing Summer's boyfriend Ethan as the new Anatomy Park host.
Aliens hold Rick and Jerry captive in a virtual reality, in an attempt to steal Rick's recipe for Concentrated Dark Matter. As Rick attempts escape, he discovers that there are multiple virtual reality layers on top of each other. Jerry, on the other hand, despite numerous system glitches, remains completely oblivious, and keeps trying to sell his advertising slogan for apples. Rick finally games the aliens by giving them a fake recipe. The aliens send Rick and Jerry on their way, and their ship explodes as they prepare the concoction.


Post-credit scene: Jerry is fired on the spot after debuting his new advertising slogan for apples in the real world. At night, a drunk Rick enters Morty's room, starts showing appreciation for him, but quickly turns on him with a knife and demands to know if Morty is a simulation. Rick then apologizes before passing out.
After killing deadly enemies in an alternative dimension, Morty complains that Rick's adventures are too dangerous and traumatizing. This leads them into a "Jack and the Beanstalk" type adventure, where Morty is in charge. He decides to steal the giant's treasure and give it to the villagers. The giant dies by accident, Rick and Morty are charged with murder but are ultimately acquitted. Rick and Morty then descend from the Giants' beanstalk realm and stop in a fairy tale pub on the way down. There, King Jellybean attempts to rape Morty, but Morty escapes. Rick wins money playing poker and gives it to the villagers. As Rick and Morty are leaveing this dimension, Rick kills King Jellybean. Meanwhile, Beth, Summer and Jerry use Rick's "Meeseeks Box" to spawn Meeseeks, blue creatures that fulfill one request and then explode. Jerry summons one Meeseeks to help him improve his golf game, and spends some time training, to no avail. The Meeseeks summons more of them to help, resulting in a increasingly larger crowd of frustrated Meeseeks. They decide to kill Jerry, but given one last chance, he ultimately demonstrates that his skills actually have improved and the Meeseeks are happy to disappear.


Post-credit scene: Two villagers find a box of incriminating photographs belonging to King Jellybean, which they burn to preserve the king's legacy as a benevolent ruler.
Morty is interested in going to the dance at his school with his classmate Jessica, so he asks Rick for a love potion. However, because Jessica has the flu, the potion becomes airborne and goes haywire, causing not only her but the whole population of Earth to fall for Morty save for blood relatives. Rick attempts to fix up an antidote, but he fails twice, ultimately causing all humans affected by the love potion to turn into mutated monsters called "Cronenbergs" (a reference to famous director of body horror films David Cronenberg). Meanwhile, Jerry visits Beth in her workplace because he is concerned about her fidelity, and they find Summer later. Rick and Morty then migrate to another dimension where their duplicates died soon after successfully curing all of Earth, thus allowing Rick and Morty to assume their roles.


Post-credit scene: Jerry, Beth and Summer are happy to stay together as the only normal human family in their post-apocalyptic mutated world, glad that Rick and Morty are gone. Two Cronenberg versions of Rick and Morty come from the "Cronenberg world" to live there as well, because their home was inhabited by Cronenbergs all along, which were accidentally transformed into normal people.
In a pawn shop in space, Rick buys Morty a sex robot. Soon after, the robot conceives Morty's alien hybrid child whom he names Morty Jr. Rick and Summer go to the sex robot's planet of origin, Gazorpazorp, to find better suited parents for Morty Jr. After discovering that the Gazorpazorpian females are the dominant gender on the planet, Rick and Summer learn that the males of this species mature in only days and are, by nature, extremely violent. Morty Jr.'s quick aging teaches Morty about parenting.


Post-credit scene: Morty Jr. goes to a talk show to talk about a book he wrote called "My (horrible) Father", which has become very successful.
As the family watches The Bachelor, Rick is dissatisfied with the quality of Earth TV so he upgrades the cable to show programming from every conceivable dimension. Eventually, they see Jerry from an alternative reality on TV. The family, minus Rick and Morty, uses Rick's goggles to see through the eyes of their duplicates in that alternative reality, where Jerry and Beth have successful lives, they never married, and Summer was never born because Beth had an abortion. Jerry, Beth and Summer have a heated discussion in which they conclude that family life is holding them back and Beth admits that Summer was an unwanted pregnancy. Summer feels unwanted and plans to run away, but Morty tells her that he and Rick themselves came from an alternate dimension (as depicted in "Rick Potion #9") and persuades her to stay. Ultimately, Beth and Jerry discover that their alternate selves are miserable in their own ways and witness them getting back together, which convinces them that they belong together too.


Post-credit scene: The family goes on vacation into an alternate reality where hamsters live in human rectums that they saw on the interdimensional TV.
Summer works in an antique shop run by the Devil, which gives away items that come with harmful curses. Rick sets up a competitor shop where he uses science to remove the curses, and the Devil is put out of business. Summer helps him to relaunch a successful dot-com company, but he betrays her and keeps the company for himself. Summer and Rick build muscle mass and publicly beat up the Devil to get revenge. Meanwhile, Jerry, helping Morty with his homework, insists that Pluto is a planet. They are abducted by Plutonians to their planet, where Jerry is mistaken for a scientist. His statements about Pluto being a planet make him instantly popular, but it is later revealed to him that Pluto is shrinking due to corporate plutonium mining. He tells Pluto citizens the truth on a public speech, causing him to be hated and deported back to Earth with Morty.


Post-credit scene: Rick and Summer merrily beat a Neo-Nazi, a bully, a member of the Westboro Baptist Church who has been holding an anti-gay sign, and an abusive dog owner.
The show's original Rick is wrongfully accused of murdering twenty-seven Ricks from alternate dimensions and kidnapping their respective Mortys. The Trans-Dimensional Council of Ricks arrests him and finds him guilty, upon discovering incriminating evidence which was actually fabricated to frame him. Rick and Morty escape and are chased by a few duplicates of themselves. The Smith household is flooded with other Ricks and Jerry develops a friendship with the good-natured "Doofus Rick". The real culprits seem to be an evil Rick and his Morty. They have been using Mortys' low intelligence brainwaves as a way to conceal themselves. They capture the original Rick and Morty, but the original Morty leads a rebellion of alternate Mortys and releases the original Rick. Rick informs the Council about the real killer, thus clearing his own name. After Rick and Morty depart, the Council discovers that Evil Rick was actually under control by an unknown puppet-master, which was Evil Morty all along. Evil Morty escapes by blending into the crowd of orphaned Morties.


Post-credit scene: Jerry waves at Doofus Rick from the window, prompting Rick to make fun of him.
Jerry and Beth participate in a reenactment of Titanic, but the ship unexpectedly fails to sink. Jerry spends some time alone with Lucy, a female janitor who eventually proves to be a deranged fan of the movie, forcing him to imitate scenes with her at gunpoint. She almost rapes Jerry, but Beth saves him. Meanwhile, Rick is left in charge of Morty and Summer, but they have a large party. Among the guests are teenagers, aliens, Gearhead, Squanchy, alternate Ricks and Abradolf Lincler (a DNA combination of Adolf Hitler and Abraham Lincoln). Not only do they make a mess, but the whole house is accidentally sent into another dimension, where Lincler seemingly dies (he actually survives). Ultimately, the guests are sent away and the house is returned to its place. Rick, Morty and Summer only have minutes to spare before Beth and Jerry arrive, so they use a contraption to freeze time, allowing them to repair the house. They watch Titanic and unanimously agree on how terrible it is.


Post-credit scene: Giant alien beasts repeatedly insert and remove Lincler and a teenager from the party in their bodies.
41 changes: 38 additions & 3 deletions lib/Index.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@ open Soup;
let print_titles = titles =>
titles |> List.iter(title => print_endline("- " ++ title));

let print_title_and_description = (title, description) => {
print_endline("- " ++ title);
print_endline(" " ++ description ++ "\n");
};

let write_descriptions_to_file = (descriptions: list(string)) => {
let file =
Unix.openfile(
"./episode-descriptions.txt",
[Unix.O_CREAT, Unix.O_WRONLY],
0o666,
);
descriptions
|> List.iter(description => {
let desc_bytes = description |> Bytes.of_string;
Unix.write(file, desc_bytes, 0, Bytes.length(desc_bytes));
ignore();
});
Unix.close(file);
};

let main = () => {
let fetch = {
/* lib/Index.re */
let url =
Uri.of_string(
"https://en.wikipedia.org/wiki/Rick_and_Morty_(season_1)",
Expand All @@ -23,16 +43,31 @@ let main = () => {
let pageTitle = soup $ "title" |> R.leaf_text;

let table = soup $ ".wikiepisodetable";
let episodeTitleNodes = soup $$ "tr.vevent td.summary";
let episodeTitleNodes = table $$ "tr.vevent td.summary";
let episodeTitles =
episodeTitleNodes
|> to_list
|> List.map(node =>
node |> texts |> List.fold_left((a, b) => a ++ b, "")
);

let episodeDescriptionNodes = table $$ "tr td.description";
let episodeDescriptions =
episodeDescriptionNodes
|> to_list
|> List.map(node =>
node |> texts |> List.fold_left((a, b) => a ++ b, "")
);

print_endline(pageTitle);
print_titles(episodeTitles);
List.iter2(
print_title_and_description,
episodeTitles,
episodeDescriptions,
);
/* print_titles(episodeTitles); */

write_descriptions_to_file(episodeDescriptions);

return(body);
}
Expand Down

0 comments on commit 5455037

Please sign in to comment.