Skip to content

Latest commit

 

History

History
105 lines (72 loc) · 2.7 KB

File metadata and controls

105 lines (72 loc) · 2.7 KB

TMDB CLI Tool in Go

A command-line interface tool that allows you to fetch and display movie information from The Movie Database (TMDB) API. This tool provides a simple way to browse different categories of movies directly from your terminal.

Features

  • Fetch movies by different categories (now playing, popular, top rated, upcoming)
  • Display detailed movie information including title, release date, overview, and rating
  • Support for pagination to browse through multiple pages of results
  • Emoji-rich output for better readability

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/tmdb-cli-tool.git
cd tmdb-cli-tool
  1. Create a .env file in the root directory based on the provided .env.example:
cp .env.example .env
  1. Edit the .env file and add your TMDB API key:
TMDB_API_KEY=your_api_key_here
TMDB_API_URL=https://api.themoviedb.org/3
  1. Build the application:
go build -o tmdb-app

Usage

The basic command structure is:

./tmdb-app -type [movie_list_type] -page [page_number]

Available Movie List Types

  • playing - Now playing movies in theaters
  • popular - Currently popular movies
  • top - Top rated movies of all time
  • upcoming - Upcoming movie releases

Examples

Fetch currently playing movies (first page):

./tmdb-app -type playing

Fetch popular movies (second page):

./tmdb-app -type popular -page 2

Fetch top rated movies (third page):

./tmdb-app -type top -page 3

Fetch upcoming movies:

./tmdb-app -type upcoming

Project Structure

  • main.go: Entry point of the application, handles command-line flags and initiates the movie fetch process
  • api/client.go: Contains functions to interact with the TMDB API
  • cmd/commands.go: Implements the command logic for fetching and displaying movie information
  • config/config.go: Handles loading environment variables from the .env file
  • models/movie.go: Defines data structures for movie information and API responses

Dependencies

This project uses standard Go libraries and does not require any external dependencies beyond the Go standard library.

Environment Variables

Variable Description
TMDB_API_KEY Your TMDB API key
TMDB_API_URL The base URL for TMDB API (default: https://api.themoviedb.org/3)

Acknowledgments