Stargate SG-1 and Atlantis viewing order Python code

I’ve compiled a viewing order for SG-1 and Stargate Atlantis by using Python and Scrapemark to scrape Wikipedia. Yes, I know, it doesn’t get much nerdier than this.
The viewing order is based on the original air dates of the episodes, this is needed as SG-1 and Atlantis had some overlap and some references were made between the two series. I think the episodes should probably be watched in chronological order, although I have to admit that the first time I watched all the episodes (yes, I’ve done it multiple times) I started with Stargate Atlantis season 1-3… Anyway, here’s the “correct” viewing order:

# Name Download Name Air date
1 Children of the Gods Stargate.SG1.S01E01 1997-07-27
2 The Enemy Within Stargate.SG1.S01E02 1997-08-01
3 Emancipation Stargate.SG1.S01E03 1997-08-08
4 The Broca Divide Stargate.SG1.S01E04 1997-08-15
5 The First Commandment Stargate.SG1.S01E05 1997-08-22
6 Brief Candle Stargate.SG1.S01E06 1997-08-29
7 Cold Lazarus Stargate.SG1.S01E07 1997-09-12
8 Thor’s Hammer Stargate.SG1.S01E08 1997-09-19
9 The Nox Stargate.SG1.S01E12 1997-09-26
10 The Torment of Tantalus Stargate.SG1.S01E09 1997-10-03
11 Bloodlines Stargate.SG1.S01E10 1997-10-10
12 Fire and Water Stargate.SG1.S01E11 1997-10-17
13 Hathor Stargate.SG1.S01E13 1997-10-24
14 Singularity Stargate.SG1.S01E14 1997-10-31
15 Cor-ai Stargate.SG1.S01E15 1998-01-23
16 Enigma Stargate.SG1.S01E16 1998-01-30
17 Solitudes Stargate.SG1.S01E18 1998-02-06
18 Tin Man Stargate.SG1.S01E17 1998-02-13
19 There But for the Grace of God Stargate.SG1.S01E19 1998-02-20
20 Politics (Part 1) Stargate.SG1.S01E20 1998-02-27
21 Within the Serpent’s Grasp (Part 2) Stargate.SG1.S01E21 1998-03-06
22 The Serpent’s Lair (Part 3) Stargate.SG1.S02E01 1998-06-26
23 In the Line of Duty Stargate.SG1.S02E02 1998-07-03
24 Prisoners Stargate.SG1.S02E03 1998-07-10
25 The Gamekeeper Stargate.SG1.S02E04 1998-07-17
26 Need Stargate.SG1.S02E05 1998-07-24
27 Thor’s Chariot Stargate.SG1.S02E06 1998-07-31
28 Message in a Bottle Stargate.SG1.S02E07 1998-08-07
29 Family Stargate.SG1.S02E08 1998-08-14
30 Secrets Stargate.SG1.S02E09 1998-08-21
31 Bane Stargate.SG1.S02E10 1998-09-25
32 The Tok’ra (Part 1) Stargate.SG1.S02E11 1998-10-02
33 The Tok’ra (Part 2) Stargate.SG1.S02E12 1998-10-09
34 Spirits Stargate.SG1.S02E13 1998-10-23
35 Touchstone Stargate.SG1.S02E14 1998-10-30
36 The Fifth Race Stargate.SG1.S02E15 1999-01-22
37 A Matter of Time Stargate.SG1.S02E16 1999-01-29
38 Holiday Stargate.SG1.S02E17 1999-02-05
39 Serpent’s Song Stargate.SG1.S02E18 1999-02-12
40 One False Step Stargate.SG1.S02E19 1999-02-19
41 Show and Tell Stargate.SG1.S02E20 1999-02-26
42 1969 Stargate.SG1.S02E21 1999-03-05
43 Out of Mind (Part 1) Stargate.SG1.S02E22 1999-03-12
44 Into the Fire (Part 2) Stargate.SG1.S03E01 1999-06-25
45 Seth Stargate.SG1.S03E02 1999-07-02
46 Fair Game Stargate.SG1.S03E03 1999-07-09
47 Legacy Stargate.SG1.S03E04 1999-07-16
48 Learning Curve Stargate.SG1.S03E05 1999-07-23
49 Point of View Stargate.SG1.S03E06 1999-07-30
50 Deadman Switch Stargate.SG1.S03E07 1999-08-06
51 Demons Stargate.SG1.S03E08 1999-08-13
52 Rules of Engagement Stargate.SG1.S03E09 1999-08-20
53 Forever in a Day Stargate.SG1.S03E10 1999-10-08
54 Past and Present Stargate.SG1.S03E11 1999-10-15
55 Jolinar’s Memories (Part 1) Stargate.SG1.S03E12 1999-10-22
56 The Devil You Know (Part 2) Stargate.SG1.S03E13 1999-10-29
57 Foothold Stargate.SG1.S03E14 1999-11-05
58 Pretense Stargate.SG1.S03E15 1999-12-12
59 Urgo Stargate.SG1.S03E16 1999-12-19
60 A Hundred Days Stargate.SG1.S03E17 2000-01-07
61 Shades of Grey Stargate.SG1.S03E18 2000-01-14
62 New Ground Stargate.SG1.S03E19 2000-01-21
63 Maternal Instinct Stargate.SG1.S03E20 2000-01-28
64 Crystal Skull Stargate.SG1.S03E21 2000-02-04
65 Nemesis (Part 1) Stargate.SG1.S03E22 2000-02-11
66 Small Victories (Part 2) Stargate.SG1.S04E01 2000-06-30
67 The Other Side Stargate.SG1.S04E02 2000-07-07
68 Upgrades Stargate.SG1.S04E03 2000-07-14
69 Crossroads Stargate.SG1.S04E04 2000-07-21
70 Divide and Conquer Stargate.SG1.S04E05 2000-07-28
71 Window of Opportunity Stargate.SG1.S04E06 2000-08-04
72 Watergate Stargate.SG1.S04E07 2000-08-11
73 The First Ones Stargate.SG1.S04E08 2000-08-18
74 Scorched Earth Stargate.SG1.S04E09 2000-08-25
75 Beneath the Surface Stargate.SG1.S04E10 2000-09-01
76 Point of No Return Stargate.SG1.S04E11 2000-09-08
77 Tangent Stargate.SG1.S04E12 2000-09-15
78 The Curse Stargate.SG1.S04E13 2000-09-22
79 The Serpent’s Venom Stargate.SG1.S04E14 2000-09-29
80 Chain Reaction Stargate.SG1.S04E15 2001-01-05
81 2010 Stargate.SG1.S04E16 2001-01-12
82 Absolute Power Stargate.SG1.S04E17 2001-01-19
83 The Light Stargate.SG1.S04E18 2001-01-26
84 Prodigy Stargate.SG1.S04E19 2001-02-05
85 Entity Stargate.SG1.S04E20 2001-02-09
86 Double Jeopardy Stargate.SG1.S04E21 2001-02-16
87 Exodus (Part 1) Stargate.SG1.S04E22 2001-02-23
88 Enemies (Part 2) Stargate.SG1.S05E01 2001-06-29
89 Threshold (Part 3) Stargate.SG1.S05E02 2001-07-06
90 Ascension Stargate.SG1.S05E03 2001-07-13
91 The Fifth Man Stargate.SG1.S05E04 2001-07-20
92 Red Sky Stargate.SG1.S05E05 2001-07-27
93 Rite of Passage Stargate.SG1.S05E06 2001-08-03
94 Beast of Burden Stargate.SG1.S05E07 2001-08-10
95 The Tomb Stargate.SG1.S05E08 2001-08-17
96 Between Two Fires Stargate.SG1.S05E09 2001-08-24
97 2001 Stargate.SG1.S05E10 2001-08-31
98 Desperate Measures Stargate.SG1.S05E11 2001-09-07
99 Wormhole X-Treme! Stargate.SG1.S05E12 2001-09-08
100 Proving Ground Stargate.SG1.S05E13 2002-03-08
101 48 Hours Stargate.SG1.S05E14 2002-03-15
102 Summit (Part 1) Stargate.SG1.S05E15 2002-03-22
103 Last Stand (Part 2) Stargate.SG1.S05E16 2002-03-29
104 Fail Safe Stargate.SG1.S05E17 2002-04-05
105 The Warrior Stargate.SG1.S05E18 2002-04-12
106 Menace Stargate.SG1.S05E19 2002-04-26
107 The Sentinel Stargate.SG1.S05E20 2002-05-03
108 Meridian Stargate.SG1.S05E21 2002-05-10
109 Revelations Stargate.SG1.S05E22 2002-05-17
110 Redemption (Part 1) Stargate.SG1.S06E01 2002-06-07
111 Redemption (Part 2) Stargate.SG1.S06E02 2002-06-14
112 Descent Stargate.SG1.S06E03 2002-06-21
113 Frozen Stargate.SG1.S06E04 2002-06-28
114 Nightwalkers Stargate.SG1.S06E05 2002-07-12
115 Abyss Stargate.SG1.S06E06 2002-07-19
116 Shadow Play Stargate.SG1.S06E07 2002-07-26
117 The Other Guys Stargate.SG1.S06E08 2002-08-02
118 Allegiance Stargate.SG1.S06E09 2002-08-09
119 Cure Stargate.SG1.S06E10 2002-08-16
120 Prometheus (Part 1) Stargate.SG1.S06E11 2002-08-23
121 Unnatural Selection (Part 2) Stargate.SG1.S06E12 2002-12-04
122 Sight Unseen Stargate.SG1.S06E13 2002-12-11
123 Smoke & Mirrors Stargate.SG1.S06E14 2002-12-18
124 Paradise Lost Stargate.SG1.S06E15 2003-01-08
125 Metamorphosis Stargate.SG1.S06E16 2003-01-15
126 Disclosure Stargate.SG1.S06E17 2003-01-22
127 Forsaken Stargate.SG1.S06E18 2003-01-29
128 The Changeling Stargate.SG1.S06E19 2003-02-05
129 Memento Stargate.SG1.S06E20 2003-02-12
130 Prophecy Stargate.SG1.S06E21 2003-02-19
131 Full Circle Stargate.SG1.S06E22 2003-02-19
132 Fallen (Part 1) Stargate.SG1.S07E01 2003-06-13
133 Homecoming (Part 2) Stargate.SG1.S07E02 2003-06-13
134 Fragile Balance Stargate.SG1.S07E03 2003-06-20
135 Orpheus Stargate.SG1.S07E04 2003-06-27
136 Revisions Stargate.SG1.S07E05 2003-07-11
137 Lifeboat Stargate.SG1.S07E06 2003-07-18
138 Enemy Mine Stargate.SG1.S07E07 2003-07-25
139 Space Race Stargate.SG1.S07E08 2003-08-01
140 Avenger 2.0 Stargate.SG1.S07E09 2003-08-08
141 Birthright Stargate.SG1.S07E10 2003-08-15
142 Evolution (Part 1) Stargate.SG1.S07E11 2003-08-22
143 Evolution (Part 2) Stargate.SG1.S07E12 2003-12-15
144 Grace Stargate.SG1.S07E13 2004-01-06
145 Fallout Stargate.SG1.S07E14 2004-01-13
146 Chimera Stargate.SG1.S07E15 2004-01-20
147 Death Knell Stargate.SG1.S07E16 2004-01-27
148 Heroes (Part 1) Stargate.SG1.S07E17 2004-02-03
149 Heroes (Part 2) Stargate.SG1.S07E18 2004-02-10
150 Resurrection Stargate.SG1.S07E19 2004-02-17
151 Inauguration Stargate.SG1.S07E20 2004-02-24
152 Lost City (Part 1) Stargate.SG1.S07E21 2004-03-02
153 Lost City (Part 2) Stargate.SG1.S07E22 2004-03-09
154 New Order (Part 1) Stargate.SG1.S08E01 2004-07-09
155 New Order (Part 2) Stargate.SG1.S08E01 2004-07-09
156 Rising (Part 1) Stargate.Atlantis.S01E01E02 2004-07-16
157 Rising (Part 2) Stargate.Atlantis.S01E01E02 2004-07-16
158 Lockdown Stargate.SG1.S08E02 2004-07-23
159 Hide and Seek Stargate.Atlantis.S01E03 2004-07-23
160 Zero Hour Stargate.SG1.S08E03 2004-07-30
161 Thirty-Eight Minutes Stargate.Atlantis.S01E04 2004-07-30
162 Icon Stargate.SG1.S08E04 2004-08-06
163 Suspicion Stargate.Atlantis.S01E05 2004-08-06
164 Avatar Stargate.SG1.S08E05 2004-08-13
165 Childhood’s End Stargate.Atlantis.S01E06 2004-08-13
166 Affinity Stargate.SG1.S08E06 2004-08-20
167 Poisoning the Well Stargate.Atlantis.S01E07 2004-08-20
168 Covenant Stargate.SG1.S08E07 2004-08-27
169 Underground Stargate.Atlantis.S01E08 2004-08-27
170 Sacrifices Stargate.SG1.S08E08 2004-09-10
171 Home Stargate.Atlantis.S01E09 2004-09-10
172 Endgame Stargate.SG1.S08E09 2004-09-17
173 The Storm (Part 1) Stargate.Atlantis.S01E10 2004-09-17
174 The Eye (Part 2) Stargate.Atlantis.S01E11 2004-11-08
175 The Defiant One Stargate.Atlantis.S01E12 2004-11-15
176 Hot Zone Stargate.Atlantis.S01E13 2004-11-22
177 Sanctuary Stargate.Atlantis.S01E14 2004-11-29
178 Before I Sleep Stargate.Atlantis.S01E15 2004-12-06
179 Gemini Stargate.SG1.S08E10 2004-12-14
180 Prometheus Unbound Stargate.SG1.S08E11 2004-12-21
181 The Brotherhood Stargate.Atlantis.S01E16 2005-01-03
182 It’s Good to Be King Stargate.SG1.S08E12 2005-01-04
183 Letters from Pegasus Stargate.Atlantis.S01E17 2005-01-10
184 Full Alert Stargate.SG1.S08E13 2005-01-11
185 The Gift Stargate.Atlantis.S01E18 2005-01-17
186 Citizen Joe Stargate.SG1.S08E14 2005-01-18
187 The Siege (Part 1) Stargate.Atlantis.S01E19 2005-01-24
188 Reckoning (Part 1) Stargate.SG1.S08E15 2005-01-25
189 The Siege (Part 2) Stargate.Atlantis.S01E20 2005-01-31
190 Reckoning (Part 2) Stargate.SG1.S08E16 2005-02-01
191 Threads Stargate.SG1.S08E17 2005-02-08
192 Moebius (Part 1) Stargate.SG1.S08E18 2005-02-15
193 Moebius (Part 2) Stargate.SG1.S08E19 2005-02-22
194 Avalon (Part 1) Stargate.SG1.S08E20 2005-07-15
195 The Siege (Part 3) Stargate.Atlantis.S02E01 2005-07-15
196 Avalon (Part 2) Stargate.SG1.S09E01 2005-07-22
197 The Intruder Stargate.Atlantis.S02E02 2005-07-22
198 Origin (Part 3) Stargate.SG1.S09E02 2005-07-29
199 Runner Stargate.Atlantis.S02E03 2005-07-29
200 The Ties That Bind Stargate.SG1.S09E03 2005-08-05
201 Duet Stargate.Atlantis.S02E04 2005-08-05
202 The Powers That Be Stargate.SG1.S09E04 2005-08-12
203 Condemned Stargate.Atlantis.S02E05 2005-08-12
204 Beachhead Stargate.SG1.S09E05 2005-08-19
205 Trinity Stargate.Atlantis.S02E06 2005-08-19
206 Ex Deus Machina Stargate.SG1.S09E06 2005-08-26
207 Instinct (Part 1) Stargate.Atlantis.S02E07 2005-08-26
208 Babylon Stargate.SG1.S09E07 2005-09-09
209 Conversion (Part 2) Stargate.Atlantis.S02E08 2005-09-09
210 Prototype Stargate.SG1.S09E08 2005-09-16
211 The Fourth Horseman (Part 1) Stargate.SG1.S09E09 2005-09-16
212 Aurora Stargate.Atlantis.S02E09 2005-09-23
213 The Lost Boys (Part 1) Stargate.Atlantis.S02E10 2005-09-23
214 The Hive (Part 2) Stargate.Atlantis.S02E11 2005-11-21
215 Epiphany Stargate.Atlantis.S02E12 2005-11-28
216 Critical Mass Stargate.Atlantis.S02E13 2005-12-05
217 Grace Under Pressure Stargate.Atlantis.S02E14 2005-12-12
218 The Tower Stargate.Atlantis.S02E15 2005-12-19
219 The Long Goodbye Stargate.Atlantis.S02E16 2006-01-02
220 The Fourth Horseman (Part 2) Stargate.SG1.S09E10 2006-01-06
221 Coup D’etat Stargate.Atlantis.S02E17 2006-01-09
222 Collateral Damage Stargate.SG1.S09E11 2006-01-13
223 Michael Stargate.Atlantis.S02E18 2006-01-16
224 Ripple Effect Stargate.SG1.S09E12 2006-01-20
225 Inferno Stargate.Atlantis.S02E19 2006-01-23
226 Stronghold Stargate.SG1.S09E13 2006-01-27
227 Allies (Part 1) Stargate.Atlantis.S02E20 2006-01-30
228 Ethon Stargate.SG1.S09E14 2006-02-03
229 Off the Grid Stargate.SG1.S09E15 2006-02-10
230 The Scourge Stargate.SG1.S09E16 2006-02-17
231 Arthur’s Mantle Stargate.SG1.S09E17 2006-02-24
232 Crusade Stargate.SG1.S09E18 2006-03-03
233 Camelot (Part 1) Stargate.SG1.S09E19 2006-03-10
234 Flesh and Blood (Part 2) Stargate.SG1.S09E20 2006-07-14
235 No Man’s Land (Part 2) Stargate.Atlantis.S03E01 2006-07-14
236 Morpheus Stargate.SG1.S10E01 2006-07-21
237 Misbegotten (Part 3) Stargate.Atlantis.S03E02 2006-07-21
238 The Pegasus Project Stargate.SG1.S10E02 2006-07-28
239 Irresistible Stargate.Atlantis.S03E03 2006-07-28
240 Insiders Stargate.SG1.S10E03 2006-08-04
241 Sateda Stargate.Atlantis.S03E04 2006-08-04
242 Uninvited Stargate.SG1.S10E04 2006-08-11
243 Progeny (Part 1) Stargate.Atlantis.S03E05 2006-08-11
244 200 Stargate.SG1.S10E05 2006-08-18
245 The Real World (Part 2) Stargate.Atlantis.S03E06 2006-08-18
246 Counterstrike Stargate.SG1.S10E06 2006-08-25
247 Common Ground Stargate.Atlantis.S03E07 2006-08-25
248 Memento Mori Stargate.SG1.S10E07 2006-09-08
249 McKay and Mrs. Miller Stargate.Atlantis.S03E08 2006-09-08
250 Company of Thieves Stargate.SG1.S10E08 2006-09-15
251 Phantoms Stargate.Atlantis.S03E09 2006-09-15
252 The Quest (Part 1) Stargate.SG1.S10E09 2006-09-22
253 The Return (Part 1) Stargate.Atlantis.S03E10 2006-09-22
254 The Return (Part 2) Stargate.Atlantis.S03E11 2006-11-20
255 Echoes Stargate.Atlantis.S03E12 2006-11-27
256 Irresponsible Stargate.Atlantis.S03E13 2006-12-04
257 Tao of Rodney Stargate.Atlantis.S03E14 2006-12-11
258 The Game Stargate.Atlantis.S03E15 2006-12-18
259 The Ark Stargate.Atlantis.S03E16 2007-01-08
260 The Quest (Part 2) Stargate.SG1.S10E10 2007-01-09
261 Sunday Stargate.Atlantis.S03E17 2007-01-15
262 Line in the Sand Stargate.SG1.S10E11 2007-01-16
263 Submersion Stargate.Atlantis.S03E18 2007-01-22
264 The Road Not Taken Stargate.SG1.S10E12 2007-01-23
265 Vengeance Stargate.Atlantis.S03E19 2007-01-29
266 The Shroud Stargate.SG1.S10E13 2007-01-30
267 First Strike (Part 1) Stargate.Atlantis.S03E20 2007-02-05
268 Bounty Stargate.SG1.S10E14 2007-02-06
269 Bad Guys Stargate.SG1.S10E15 2007-02-13
270 Talion Stargate.SG1.S10E16 2007-02-20
271 Family Ties Stargate.SG1.S10E17 2007-02-27
272 Dominion Stargate.SG1.S10E18 2007-03-06
273 Unending Stargate.SG1.S10E19 2007-03-13
274 Adrift (Part 2) Stargate.Atlantis.S04E01 2007-09-28
275 Lifeline (Part 3) Stargate.Atlantis.S04E02 2007-10-05
276 Reunion Stargate.Atlantis.S04E03 2007-10-12
277 Doppelganger Stargate.Atlantis.S04E04 2007-10-19
278 Travelers Stargate.Atlantis.S04E05 2007-10-26
279 Tabula Rasa Stargate.Atlantis.S04E06 2007-11-02
280 Missing Stargate.Atlantis.S04E07 2007-11-09
281 The Seer Stargate.Atlantis.S04E08 2007-11-16
282 Miller’s Crossing Stargate.Atlantis.S04E09 2007-11-30
283 This Mortal Coil (Part 1) Stargate.Atlantis.S04E10 2007-12-07
284 Be All My Sins Remember’d (Part 2) Stargate.Atlantis.S04E11 2008-01-04
285 Spoils of War (Part 3) Stargate.Atlantis.S04E12 2008-01-11
286 Quarantine Stargate.Atlantis.S04E13 2008-01-18
287 Harmony Stargate.Atlantis.S04E14 2008-01-25
288 Outcast Stargate.Atlantis.S04E15 2008-02-01
289 Trio Stargate.Atlantis.S04E16 2008-02-08
290 Midway Stargate.Atlantis.S04E17 2008-02-15
291 The Kindred (Part 1) Stargate.Atlantis.S04E18 2008-02-22
292 The Kindred (Part 2) Stargate.Atlantis.S04E19 2008-02-29
293 The Last Man (Part 1) Stargate.Atlantis.S04E20 2008-03-07
294 Search and Rescue (Part 2) Stargate.Atlantis.S05E01 2008-07-11
295 The Seed Stargate.Atlantis.S05E02 2008-07-18
296 Broken Ties Stargate.Atlantis.S05E03 2008-07-25
297 The Daedalus Variations Stargate.Atlantis.S05E04 2008-08-01
298 Ghost in the Machine Stargate.Atlantis.S05E05 2008-08-15
299 The Shrine Stargate.Atlantis.S05E06 2008-08-22
300 Whispers Stargate.Atlantis.S05E07 2008-09-05
301 The Queen Stargate.Atlantis.S05E08 2008-09-12
302 Tracker Stargate.Atlantis.S05E09 2008-09-19
303 First Contact (Part 1) Stargate.Atlantis.S05E10 2008-09-26
304 The Lost Tribe (Part 2) Stargate.Atlantis.S05E11 2008-10-10
305 Outsiders Stargate.Atlantis.S05E12 2008-10-17
306 Inquisition Stargate.Atlantis.S05E13 2008-10-24
307 The Prodigal Stargate.Atlantis.S05E14 2008-11-07
308 Remnants Stargate.Atlantis.S05E15 2008-11-14
309 Brain Storm Stargate.Atlantis.S05E16 2008-11-21
310 Infection Stargate.Atlantis.S05E17 2008-12-05
311 Identity Stargate.Atlantis.S05E18 2008-12-12
312 Vegas Stargate.Atlantis.S05E19 2009-01-02
313 Enemy at the Gate Stargate.Atlantis.S05E20 2009-01-09

If you’re interested in the code, here it is:

import scrapemark, time, datetime, math

def dateToUnixtime(date):
	time_format = '%Y-%m-%d'
	return time.mktime(time.strptime(date, time_format))

def scrapeEpisodes(url):
	return scrapemark.scrape("""
		{*
		<td class="summary">"<b>{{ [episode].name }}</b>"</td>
		<span class="bday dtstart published updated">{{ [episode].date }}</span>
		*}
		""",
		url=url)

def episodeNumber(epn, maxn, series):
	epnr = epn%maxn
	if epnr == 0: epnr = maxn
	epnr = str(epnr).zfill(2)

	# The pilot was a double-episode
	if epn < 3 and series == 'SGA': epnr = '01E02'

	return 'E'+epnr

def seasonNumber(epn, maxn, pad = 0):
	return 'S'+str(int(math.ceil(float(epn) / maxn)) + pad).zfill(2)

episodes = []

SG1episodes = scrapeEpisodes('http://en.wikipedia.org/wiki/List_of_Stargate_SG-1_episodes')

i = 0
for episode in SG1episodes['episode']:
	timestamp = dateToUnixtime(episode['date'])
	i += 1

	# The SG-1 seasons got shorter after season 7...
	if i < 22:
		downloadname = 'Stargate.SG1.'+seasonNumber(i, 21)+episodeNumber(i, 21, 'SG-1')
	elif i < 155 and i > 21:
		downloadname = 'Stargate.SG1.'+seasonNumber(i-21, 22, 1)+episodeNumber(i-21, 22, 'SG-1')
	else:
		downloadname = 'Stargate.SG1.'+seasonNumber(i-154, 20, 7)+episodeNumber(i-154, 20, 'SG-1')

	episodes.append({'name' : episode['name'], 'airdate' : episode['date'], 'timestamp' : timestamp, 'downloadname' : downloadname})

SGAepisodes = scrapeEpisodes('http://en.wikipedia.org/wiki/List_of_Stargate_Atlantis_episodes')

i = 0
for episode in SGAepisodes['episode']:
	timestamp = dateToUnixtime(episode['date'])
	i += 1
	downloadname = 'Stargate.Atlantis.'+seasonNumber(i, 20)+episodeNumber(i, 20, 'SGA')
	episodes.append({'name' : episode['name'], 'airdate' : episode['date'], 'timestamp' : timestamp, 'downloadname' : downloadname})

episodes = sorted(episodes, key=lambda ep: ep['timestamp'])

i = 0
print '<table>'
print '<tr><td>#</td><td>Name</td><td>Download Name</td><td>Air date</td></tr>'
for episode in episodes:
	i += 1
	print '<tr><td>'+str(i)+'</td><td>'+episode['name']+'</td><td>'+episode['downloadname']+'</td><td>'+episode['airdate']+'</td></tr>'
print '</table>'

It outputs a html table with all the episodes, as seen in this blog post. If you want to try it yourself, here’s a zip with the code and scrapemark.

4 thoughts on “Stargate SG-1 and Atlantis viewing order Python code

  1. Pingback: Tweets that mention Stargate SG-1 and Atlantis viewing order Python code | Arvtard -- Topsy.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>