Giter VIP home page Giter VIP logo

song-chords's Introduction

Song Chords to PDF

Description:

This project is written as the final assignment of CS50p - Harvard introduction to programming in python and is meant for educational purposes.

This program implements s HTML scraper and a PDF exporter which scrapes and generates a file with Chords and Lyrics for famous songs available in Internet Chord database. The program can be run on the terminal, and can output to the standard terminal output or to a PDF.

python project.py url -o output.pdf

HTML Song Parser

The HTMLSongParser class is responsible for parsing HTML content, specifically tailored for song lyrics websites. It utilizes the HTMLParser module to traverse the HTML structure and extract relevant data such as lyrics and chord notations. Key features include:

Identification of lyric sections and chord notations within the HTML markup.
Organization of lyrics into sections and chords with associated lyrics.
Handling of special cases like section headers and line breaks.

Song PDF Exporter

The SongPdfExporter class extends the FPDF library to facilitate the creation of PDF documents containing formatted song lyrics. It offers methods for adding chords, lyrics, and section headers to the PDF output. Notable functionalities include:

Generation of PDF pages with chords, lyrics, and section headers arranged in a readable format.
Customization options for text formatting and styling within the PDF document.

Main Execution:

The main section of the script handles command-line arguments using argparse, allowing users to specify a song URL and optionally an output file for the generated PDF. Key actions performed include:

Retrieval of the song's HTML content via HTTP request.
Parsing of the HTML content using the HTMLSongParser.
Conditional execution based on whether an output file is specified:
    If an output file is provided, the parsed song lyrics are exported to a PDF using SongPdfExporter.
    Otherwise, the parsed lyrics are printed to the console in a formatted manner.

Additional Features:

Utilization of colorama for adding color to console output, enhancing readability.
Handling of special characters like curly quotes for improved text representation.

Usage:

Users can run the program from the command line, providing a song URL as input. Optionally, they can specify an output file for the generated PDF. The program then retrieves, parses, and formats the song lyrics accordingly, either displaying them in the console or saving them to a PDF file.

This Python program offers a convenient solution for musicians and enthusiasts to extract, format, and archive song lyrics from online sources with ease and flexibility.

song-chords's People

Contributors

andrsbtrg avatar

Stargazers

Abdelrahman Omar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.