Introducing instiz, my first published library on PyPI
Tags: python, showdev, opensource
Published: 2018-11-23 09:07:01

---
title: Introducing instiz, my first published library on PyPI
published: true
description: instiz, an open-source wrapper for iChart.
tags: #python #showdev #opensource
---

Hello, I'd like to introduce `instiz`, a wrapper to the [iChart chart website](http://ichart.instiz.net) for Python 3+. iChart is a real-time chart website for Korean music.

{% github Chromadream/instiz %} 


## Background

I recently started contributing to [/r/kpop](https://github.com/rkpop) as a technical moderator. A glance on the organization may show that it's quite unusual for a Reddit community to use this much code, but it really helped the moderator's job, and provide value-addition to the users of the community. 

## Why does instiz exist?

The subreddit has a real-time charting widget of the songs, which was scraped from iChart hourly. 

![old chart](https://thepracticaldev.s3.amazonaws.com/i/uwno3xssdb4cwc8ndhys.png)

However, as Reddit pushes the redesign, a port of the widget to the redesign is required, so that there is no function disparity between users of the old site and the new site. And so, I started the porting attempt. However, a glance of the source code of the currently-running widget reveals a horribly nested mess. Not only that, the scraper and parser are coupled tightly to the actual updating function.

`instiz` is initially created to provide separation of concern between scraping process and widget update process. It can also be used for any kind of scripts, bots, or any programs that utilizes iChart's data.

## Features

Even though the main functionality of `instiz` is fairly straightforward, which is to scrape and process the data from iChart, there are some noteworthy additional features inside it.

* Sane artist name processing. 

On iChart's site, artist names are inconsistently formatted. Examples include `제니 (JENNIE)`, `TWICE (트와이스)`, `아이유(IU)`, and `Queen(퀸)`. instiz ensures that Korean and English names are pre-processed and can be retrieved easily by the library's user, without the need of additional processing.

Code example:

```python

from instiz import iChart

ichart = iChart()
first_place = ichart.get_next_entry()
nice_title = first_place.nice_title # "JENNIE - SOLO"
raw_artist_name = first_place.artist.raw_name # "제니 (JENNIE)"
english_artist_name = first_place.artist.english_name # "JENNIE"
korean_artist_name = first_place.artist.korean_name # "제니"

```

* API refresh.

A refresh function is provided, so that developer doesn't have to initialize a new instance of the class each time a new set of data is needed.

Code example:

```python

from instiz import iChart

ichart = iChart()
top_10 = ichart.realtime_top_10()
ichart.refresh()
top_10 = ichart.realtime_top_10()

```

* It's fully open-sourced.

`instiz` is published under MIT, and there are some "good first issue" for people wanting to start working on open-source culture. However, I realized that there are some items that usually is on open-source project missing from `instiz`. Please help me fulfil that by making a pull request.

## Thank you.

Thank you for reading this post all the way to the bottom. I really appreciate it. Have a good day.