Complete Workflow
Crunchyroll Downloader — Practical Scripting
Course 1 · Chapter 5 · Complete Workflow
🔄 Complete Workflow
Orchestrate the complete end-to-end workflow: load config, login with JWT, fetch episodes, parse data, and export to CSV. This brings all previous components together.
📋 The Workflow
def main():
print("🚀 CRUNCHYROLL DOWNLOADER")
# Step 1: Load config
config = Config()
if not config.validate():
return False
# Step 2: Try cached token, or login
token = load_cached_token(config.token_cache)
if not token:
print("🔐 Logging in...")
token = login(config)
if not token:
return False
save_token(token, config.token_cache)
# Step 3: Create client and fetch episodes
print("📡 Fetching episodes...")
client = CrunchyrollClient(config, token)
episodes = client.get_episodes()
print(f"✅ Fetched {len(episodes)} episodes")
# Step 4: Export to CSV
print("💾 Exporting to CSV...")
export_to_csv(episodes, "episodes.csv")
print("✅ Saved to episodes.csv")
return True
if __name__ == "__main__":
main()
💻 Coding Challenges
Challenge 1: JWT Login Flow
Implement complete login: config → login → cache token → return token.
Challenge 2: Episode Export
Export episode data to CSV with columns: show, episode, date watched.
Challenge 3: Complete Script
Build main() that orchestrates entire workflow with error handling.