karaoke


Namekaraoke JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryKaraoke is a lightweight Python library designed to facilitate interactions with song Lyrics.
upload_time2024-10-15 21:36:28
maintainerNone
docs_urlNone
author0x15BA88FF
requires_pythonNone
licenseNone
keywords karaoke music lrc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Karaoke.py

## Overview

**Karaoke** is a lightweight Python library designed to facilitate interactions
with song LRC (Lyric) files. It allows for easy parsing, management, and
retrieval of song lyrics along with their corresponding timestamps.

## Installation

To use the Karaoke library, simply clone the repository or download the
`karaoke.py` file and include it in your project.

```bash
git clone https://github.com/pascall-de-creator/karaoke.py
```

## Features

- **Parsing LRC Files:** Load and parse LRC formatted lyrics, extracting
  timestamps and lyrics.
- **Timestamp Management:** Convert timestamps from LRC format to milliseconds
  for precise timing.
- **Current Lyric Tracking:** Keep track of the current lyric based on a given
  timestamp.

## Usage

### Importing the Library

```python
from karaoke import Karaoke
```

### Creating an Instance

```python
karaoke = Karaoke()
```

### Parsing LRC Data

To parse LRC data, use the `parse` method:

```python
lrc_data = """
[00:01.00]Line 1
[00:05.00]Line 2
[00:10.00]Line 3
"""

karaoke.parse(lrc_data)
```

### Accessing Lyrics

You can access all the lyrics using the `lyrics` property:

```python
all_lyrics = karaoke.lyrics
print(all_lyrics)  # Output: ['Line 1', 'Line 2', 'Line 3']
```

### Getting Current Lyric

To get the currently active lyric based on the timestamp set, use the
`current_lyric` property:

```python
karaoke.set_current_lyric(6000)  # Set current time to 6 seconds
print(karaoke.current_lyric)  # Output: 'Line 2'
```

### Clean and Validate LRC Data

The `check` method validates the LRC data:

```python
karaoke.check(lrc_data)  # Raises ValueError if the data is invalid
```

The `clean` method can be used to clean up LRC data by removing blank lines:

```python
cleaned_lrc = karaoke.clean(lrc_data, clean_blanklines=True)
```

### Timestamp Conversion

Convert LRC timestamp to milliseconds with:

```python
ms = karaoke.timestamp_to_ms("[00:01.00]")  # Output: 1000
```

### Finding Lyric Index

To find the index of a lyric based on the target time:

```python
index = karaoke.find_lyric_index(6000)  # Output: 1
```

## Class Reference

### `Karaoke`

#### Properties

- `lyrics`: Returns a list of all lyrics.
- `lyric_index`: Returns the index of the currently active lyric.
- `current_lyric`: Returns the currently active lyric.

#### Methods

- `check(lrc: str)`: Validates the provided LRC data.
- `clean(lrc: str, clean_blanklines: bool)`: Cleans the LRC data by removing
  timestamps or blank lines.
- `timestamp_to_ms(timestamp: str) -> int`: Converts LRC timestamp to milliseconds.
- `parse(lrc: str, clean_blanklines: bool = False)`: Parses the LRC data into an
  internal structure.
- `find_lyric_index(target_time: int) -> int`: Finds the index of the lyric that
  corresponds to a given time.
- `set_current_lyric(target_time: int)`: Sets the current lyric based on a
  target time.

## Example

Here's a complete example demonstrating the library's functionality:

```python
from karaoke import Karaoke

karaoke = Karaoke()

lrc_data = """
[00:01.00]Line 1
[00:05.00]Line 2
[00:10.00]Line 3
"""

karaoke.parse(lrc_data)

karaoke.set_current_lyric(6000)  # Set current time to 6 seconds
print(karaoke.current_lyric)  # Output: 'Line 2'
```

## Conclusion

The Karaoke library is a simple yet powerful tool for managing song lyrics and
their timestamps. Its clean API and lightweight structure make it easy to
integrate into various projects. Enjoy your karaoke sessions!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "karaoke",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "karaoke, music, lrc",
    "author": "0x15BA88FF",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/84/a2/b1927eefeecb55bd04682c59fc0fef80234f44f91f0c8b6b3cdda8bf5f42/karaoke-0.0.2.tar.gz",
    "platform": null,
    "description": "# Karaoke.py\n\n## Overview\n\n**Karaoke** is a lightweight Python library designed to facilitate interactions\nwith song LRC (Lyric) files. It allows for easy parsing, management, and\nretrieval of song lyrics along with their corresponding timestamps.\n\n## Installation\n\nTo use the Karaoke library, simply clone the repository or download the\n`karaoke.py` file and include it in your project.\n\n```bash\ngit clone https://github.com/pascall-de-creator/karaoke.py\n```\n\n## Features\n\n- **Parsing LRC Files:** Load and parse LRC formatted lyrics, extracting\n  timestamps and lyrics.\n- **Timestamp Management:** Convert timestamps from LRC format to milliseconds\n  for precise timing.\n- **Current Lyric Tracking:** Keep track of the current lyric based on a given\n  timestamp.\n\n## Usage\n\n### Importing the Library\n\n```python\nfrom karaoke import Karaoke\n```\n\n### Creating an Instance\n\n```python\nkaraoke = Karaoke()\n```\n\n### Parsing LRC Data\n\nTo parse LRC data, use the `parse` method:\n\n```python\nlrc_data = \"\"\"\n[00:01.00]Line 1\n[00:05.00]Line 2\n[00:10.00]Line 3\n\"\"\"\n\nkaraoke.parse(lrc_data)\n```\n\n### Accessing Lyrics\n\nYou can access all the lyrics using the `lyrics` property:\n\n```python\nall_lyrics = karaoke.lyrics\nprint(all_lyrics)  # Output: ['Line 1', 'Line 2', 'Line 3']\n```\n\n### Getting Current Lyric\n\nTo get the currently active lyric based on the timestamp set, use the\n`current_lyric` property:\n\n```python\nkaraoke.set_current_lyric(6000)  # Set current time to 6 seconds\nprint(karaoke.current_lyric)  # Output: 'Line 2'\n```\n\n### Clean and Validate LRC Data\n\nThe `check` method validates the LRC data:\n\n```python\nkaraoke.check(lrc_data)  # Raises ValueError if the data is invalid\n```\n\nThe `clean` method can be used to clean up LRC data by removing blank lines:\n\n```python\ncleaned_lrc = karaoke.clean(lrc_data, clean_blanklines=True)\n```\n\n### Timestamp Conversion\n\nConvert LRC timestamp to milliseconds with:\n\n```python\nms = karaoke.timestamp_to_ms(\"[00:01.00]\")  # Output: 1000\n```\n\n### Finding Lyric Index\n\nTo find the index of a lyric based on the target time:\n\n```python\nindex = karaoke.find_lyric_index(6000)  # Output: 1\n```\n\n## Class Reference\n\n### `Karaoke`\n\n#### Properties\n\n- `lyrics`: Returns a list of all lyrics.\n- `lyric_index`: Returns the index of the currently active lyric.\n- `current_lyric`: Returns the currently active lyric.\n\n#### Methods\n\n- `check(lrc: str)`: Validates the provided LRC data.\n- `clean(lrc: str, clean_blanklines: bool)`: Cleans the LRC data by removing\n  timestamps or blank lines.\n- `timestamp_to_ms(timestamp: str) -> int`: Converts LRC timestamp to milliseconds.\n- `parse(lrc: str, clean_blanklines: bool = False)`: Parses the LRC data into an\n  internal structure.\n- `find_lyric_index(target_time: int) -> int`: Finds the index of the lyric that\n  corresponds to a given time.\n- `set_current_lyric(target_time: int)`: Sets the current lyric based on a\n  target time.\n\n## Example\n\nHere's a complete example demonstrating the library's functionality:\n\n```python\nfrom karaoke import Karaoke\n\nkaraoke = Karaoke()\n\nlrc_data = \"\"\"\n[00:01.00]Line 1\n[00:05.00]Line 2\n[00:10.00]Line 3\n\"\"\"\n\nkaraoke.parse(lrc_data)\n\nkaraoke.set_current_lyric(6000)  # Set current time to 6 seconds\nprint(karaoke.current_lyric)  # Output: 'Line 2'\n```\n\n## Conclusion\n\nThe Karaoke library is a simple yet powerful tool for managing song lyrics and\ntheir timestamps. Its clean API and lightweight structure make it easy to\nintegrate into various projects. Enjoy your karaoke sessions!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Karaoke is a lightweight Python library designed to facilitate interactions with song Lyrics.",
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [
        "karaoke",
        " music",
        " lrc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b587244fea3322d1b3266225ca31d5c144dbb660a1f815b2b4b354a829bb1d06",
                "md5": "a9718123f2cdd8cd3cc3c07590c83812",
                "sha256": "9f35978976b9542a42cad992329375606f185aa1250bdd55233ecfde5617d76a"
            },
            "downloads": -1,
            "filename": "karaoke-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a9718123f2cdd8cd3cc3c07590c83812",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5047,
            "upload_time": "2024-10-15T21:36:27",
            "upload_time_iso_8601": "2024-10-15T21:36:27.799821Z",
            "url": "https://files.pythonhosted.org/packages/b5/87/244fea3322d1b3266225ca31d5c144dbb660a1f815b2b4b354a829bb1d06/karaoke-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "84a2b1927eefeecb55bd04682c59fc0fef80234f44f91f0c8b6b3cdda8bf5f42",
                "md5": "fc4e5a50fcb52d27ba5ac1b4d48944a3",
                "sha256": "cf527e83c6425a2b34d950f143fec41da5ebbebd866a8fe540d9dbc88256dfcb"
            },
            "downloads": -1,
            "filename": "karaoke-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "fc4e5a50fcb52d27ba5ac1b4d48944a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5337,
            "upload_time": "2024-10-15T21:36:28",
            "upload_time_iso_8601": "2024-10-15T21:36:28.783646Z",
            "url": "https://files.pythonhosted.org/packages/84/a2/b1927eefeecb55bd04682c59fc0fef80234f44f91f0c8b6b3cdda8bf5f42/karaoke-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 21:36:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "karaoke"
}
        
Elapsed time: 4.16979s