Python implementation for Qianqian Music MP3 download

Entering the Qianqian Music homepage and selecting Jay Chou’s “Confession Balloon” reveals that it’s a 2016 song with no preview available, which is sad. Is there a way to get the MP3 file? The answer is yes. A runnable program for music download is available at the end of the article.

Without further ado, I opened the charts and chose a new song that could be previewed; “Sheng Pi Zi” was the first one I could listen to.

Python implementation for Qianqian Music MP3 download

1. Analyze API information

Opening the developer tools, I found that music files are definitely submitted through an API. Among many requests, I found a request that could retrieve music files. See the image below:

Python implementation for Qianqian Music MP3 download

Check the request details:

Python implementation for Qianqian Music MP3 download The songid parameter can be found in the current URL: http://music.taihe.com/song/611238837. It’s simple. from should be “web” or “app”, etc. The format defining the return data type doesn’t need to be changed. method doesn’t need to be changed. The _ parameter is a 13-digit timestamp. callback is the prefix of the returned JSON data. The 1546915161467 after the underscore is a 13-digit timestamp, while the preceding 17200943498528136486 is unknown. We’ll try to use the known parameters to see if we can retrieve information without changing the unknown content.

……

阅读全文

Python implementation for Qianqian Music MP3 download

Entering the Qianqian Music homepage and selecting Jay Chou’s “Confession Balloon” reveals that it’s a 2016 song with no preview available, which is sad. Is there a way to get the MP3 file? The answer is yes. A runnable program for music download is available at the end of the article.

Without further ado, I opened the charts and chose a new song that could be previewed; “Sheng Pi Zi” was the first one I could listen to.

Python implementation for Qianqian Music MP3 download

1. Analyze API information

Opening the developer tools, I found that music files are definitely submitted through an API. Among many requests, I found a request that could retrieve music files. See the image below:

Python implementation for Qianqian Music MP3 download Check the request details:

Python implementation for Qianqian Music MP3 download

The songid parameter can be found in the current URL: http://music.taihe.com/song/611238837. It’s simple. from should be “web” or “app”, etc. The format defining the return data type doesn’t need to be changed. method doesn’t need to be changed. The _ parameter is a 13-digit timestamp. callback is the prefix of the returned JSON data. The 1546915161467 after the underscore is a 13-digit timestamp, while the preceding 17200943498528136486 is unknown. We’ll try to use the known parameters to see if we can retrieve information without changing the unknown content.

……

阅读全文

Mounting an External Hard Drive in Linux

After a machine restart, the external hard drive wasn’t recognized and needed to be remounted. However, after using fdisk -l, the external hard drive was nowhere to be found, making it impossible to mount.

Mounting an External Hard Drive in Linux

How to Mount a Disk

First, use fdisk -l to check the current hard drive status.

    ➜  ~ fdisk -l 
    WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

    Disk /dev/sdb: 320.1 GB, 320072933376 bytes, 625142448 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: gpt
    Disk identifier: AF1B577B-830C-4026-AC5F-37870D362B3C

    #         Start         End    Size  Type            Name
    1          2048      411647    200M  EFI System      EFI System Partition
    2        411648     2508799      1G  Microsoft basic
    3       2508800   625141759  296.9G  Linux LVM

    Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    Disk /dev/mapper/centos-swap: 3623 MB, 3623878656 bytes, 7077888 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    Disk /dev/mapper/centos-home: 261.5 GB, 261468717056 bytes, 510681088 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    Disk /dev/sda: 1000.2 GB, 1000170586112 bytes, 1953458176 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x16f2a91f

          Device Boot      Start        End    Blocks  Id  System
    /dev/sda1             1 4294967295 2147483647+ ee  GPT

Here, my external hard drive is 1TB, which means it’s /dev/sda1. So, I can use the mount command to mount it:

……

阅读全文

Drawing Violin Plots with Seaborn

Introduction

A violin plot is used to display the distribution and probability density of multiple data groups. Similar to a box plot, it offers a better representation of data density. Violin plots are particularly useful when dealing with very large datasets that are difficult to display individually. Python’s Seaborn package makes it very convenient to create violin plots.

Parameters

Drawing Violin Plots with Seaborn

The parameters corresponding to each position in a violin plot are shown above. The middle line represents the box plot data, specifically the 25th, 50th (median), and 75th percentiles. The thin lines indicate the 95% confidence interval.

Drawing Violin Plots with Seaborn

Single Variable Data

While a box plot would suffice for a single variable, a violin plot can certainly be used as well:

    import seaborn as sns
    sns.set(color_codes=True)
    sns.set_style("white")
    df = sns.load_dataset('iris')
    sns.violinplot( y=df["sepal_length"] )

Drawing Violin Plots with Seaborn

……

阅读全文

Five Easy Steps to Achieve Linux Passwordless Login

SSH, which stands for Secure Shell, is a widely used and reliable program for securely executing commands remotely on Linux systems. SCP, used for secure file transfers, is also based on the SSH security protocol.

When you have many servers, frequently typing passwords can be quite troublesome. So, how can you log in without a password while maintaining security? Of course, it’s possible. Here, we’ll outline five steps to achieve passwordless login for Linux servers such as RHEL/CentOS 7.x/6.x/5.x and Fedora.

Five Easy Steps to Achieve Linux Passwordless Login

Let’s look at the environment:

    SSH Client : 192.168.1.12 ( Mac )
    SSH Remote Host : 192.168.1.11 ( CentOS 7 )

This article will demonstrate passwordless login from a Mac to a remote CentOS 7 server.

1. Generate SSH-Keygen Key Pair on Your Local Mac

First, use the following command in your Mac terminal to generate a key pair:

……

阅读全文

The difference between shadowcopy and deepcopy in python

In python, it is common to need to copy specific objects, and you might encounter various bugs because understanding the difference between these three operations is key: assignment, shallow copy, and deep copy.

“The difference between shadowcopy and deepcopy in python”

Assignment (=), shallow copy (copy), and deep copy (deepcopy) are relatively easy to distinguish regarding assignment vs. copying, but shallow copy and deep copy are harder to differentiate.

The assignment statement does not copy the object; it simply binds the variable to the object. Any change to one object will affect the other. Copying allows you to change one object without affecting the other.

The difference between shallow and deep copy is that shallow copy does not affect the other object when values change, but adding or deleting elements can affect it. Deep copy creates a completely independent object, and changes to one will not affect the other.

……

阅读全文

python3 requests module usage examples

The network module in python3 is much more convenient compared to python2. The requests package combines several python2 packages. This article explains the usage of requests with examples, serving as a review and future reference.……

阅读全文

Detailed Explanation of Python Magic Methods

What are magic methods? Of course, they have nothing to do with magicians. They are everywhere in object-oriented Python. They are special methods that allow you to add “magic” to your classes. These methods are automatically called during certain operations and represent the wisdom of Python’s object-oriented design.……

阅读全文

boxes: An Interesting Command-Line String Shaping Tool

When frequently using GitHub, you may notice others’ repository code help information or website source code always has beautifully shaped patterns made of strings, but your own code lacks these decorations and looks plain. So how can you generate such stylish string shapes? The answer is to use the interesting command-line string shaping tool boxes.……

阅读全文