Audio file downloading method and device based on Spotify application and storage medium
Obtaining and decrypting audio files through Spotify applications and APIs solve the problem of low quality of audio content downloaded through unofficial channels, and achieve the same audio quality and download security as official sources.
Patent Information
- Application Number
- CN202410849457.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-11-08
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The audio content downloaded by non-official channels in the prior art has low quality and is incomparable to the audio content from official sources.
Through the login operation of the Spotify application, use the Spotify API to obtain the link media information of the song, extract the trackId and convert it to gid, obtain the target audio file based on the gid, and ensure the quality of the audio file through decryption and lossless repair operations.
Ensure that the downloaded audio files are of the same quality as the official source, avoid the possible quality problems of unofficial channels, and ensure the security of the download operation through legal authorization information.
Smart Images

Figure CN118921183A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method, device and storage medium for downloading audio files based on a Spotify application. Background Art
[0002] Spotify offers a variety of audio content including music, podcasts and audiobooks, which users can listen to online or download through the Spotify app on different devices such as smartphones, computers, tablets and smart speakers.
[0003] Because it provides a large number of authorized, high-quality songs, many requirements have arisen, such as users wanting to play music on Spotify in their favorite music players and devices on different platforms, and being able to edit Spotify music, etc. Currently, the audio content downloaded by searching from Youtube cannot be compared with the audio content from the official source in terms of audio quality. A new technical solution is needed to solve the above technical problems. Summary of the invention
[0004] The main purpose of the present invention is to solve the technical problem of low quality stability of audio content downloaded from unofficial channels.
[0005] A first aspect of the present invention provides a method for downloading an audio file based on a Spotify application, the method for downloading an audio file based on a Spotify application comprising:
[0006] When a song download request is detected, the Spotify app login operation is performed;
[0007] When the login operation is successfully performed, obtaining the link media information specified by the song download request through the Spotify API authorized by the Spotify application;
[0008] Extract trackId from the link media information;
[0009] Convert the trackId to a gid;
[0010] Based on the gid, a target audio file of a target song is obtained through the Spotify application.
[0011] Optionally, in a first implementation of the first aspect of the present invention, the step of obtaining a target audio file of a target song through the Spotify application based on the gid includes:
[0012] Obtain a download link corresponding to the trackId based on the gid;
[0013] Execute a file download operation according to the download link to obtain an encrypted file;
[0014] A decryption operation is performed on the encrypted file to obtain a target audio file of the target song.
[0015] Optionally, in a second implementation of the first aspect of the present invention, the step of performing a decryption operation on the encrypted file to obtain a target audio file of the target song includes:
[0016] Generate a key according to the gid and preset cdm technical solution information;
[0017] The encrypted file is decrypted according to the key to obtain the target audio file of the target song.
[0018] Optionally, in a third implementation of the first aspect of the present invention, the step of performing a decryption operation on the encrypted file to obtain a target audio file of the target song includes:
[0019] A pssh value is generated according to the gid, and a decryption operation is performed on the encrypted file according to the pssh value to obtain a target audio file of the target song.
[0020] Optionally, in a fourth implementation of the first aspect of the present invention, the step of obtaining a target audio file of a target song through the Spotify application based on the gid includes:
[0021] Based on the gid, obtaining a to-be-processed file of the target song through the Spotify application;
[0022] Calling a preset ffmpeg program to perform a lossless repair operation and an ID3 information adding operation on the file to be processed, so as to obtain a file to be converted;
[0023] The ffmpeg program is called to convert the file to be converted into a preset format to obtain the target audio file.
[0024] Optionally, in a fifth implementation of the first aspect of the present invention, the step of performing a login operation of the Spotify application includes:
[0025] Log in to the Spotify app based on the preset membership account information.
[0026] Optionally, in a sixth implementation of the first aspect of the present invention, the step of performing a login operation of the Spotify application includes:
[0027] Extracting the login verification information carried in the song download request;
[0028] The login operation of the Spotify application is performed according to the login verification information.
[0029] Optionally, in a seventh implementation manner of the first aspect of the present invention, after the step of obtaining the target audio file of the target song through the Spotify application based on the gid, the method further includes:
[0030] A playlist is generated according to the target audio file.
[0031] A second aspect of the present invention provides an audio file downloading device based on the Spotify application, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected via a line; the at least one processor calls the instructions in the memory so that the audio file downloading device based on the Spotify application executes the above-mentioned audio file downloading method based on the Spotify application.
[0032] A third aspect of the present invention provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer executes the above-mentioned audio file downloading method based on the Spotify application.
[0033] In an embodiment of the present invention, when a song download request is detected, a login operation of the Spotify application is performed; when the login operation is successfully performed, the link media information specified by the song download request is obtained through the Spotify API authorized by the Spotify application; the trackId is extracted from the link media information; the trackId is converted into a gid; based on the gid, the target audio file of the target song is obtained through the Spotify application. The use of the user's legal authorization information (login credentials and API access) ensures the security of the music download operation and avoids unauthorized downloading. The audio files obtained through Spotify's API are officially authorized, which can guarantee the sound quality and version of the download and avoid quality problems that may exist in unofficial channels. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 Schematic diagram of an embodiment of a method for downloading an audio file based on a Spotify application in an embodiment of the present invention;
[0035] Figure 2 1 is a schematic diagram of a specific embodiment of step 105 of the method for downloading an audio file based on the Spotify application in an embodiment of the present invention;
[0036] Figure 3 1 is a schematic diagram of a specific embodiment of step 1053 of the method for downloading an audio file based on the Spotify application in an embodiment of the present invention;
[0037] Figure 4 1 is another specific embodiment diagram of step 105 of the method for downloading an audio file based on the Spotify application in an embodiment of the present invention;
[0038] Figure 5 Schematic diagram of an embodiment of an audio file downloading device based on the Spotify application in an embodiment of the present invention. DETAILED DESCRIPTION
[0039] Embodiments of the present invention provide a method, device and storage medium for downloading audio files based on a Spotify application.
[0040] The embodiments disclosed in the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments disclosed in the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments disclosed in the present invention are only for exemplary purposes and are not intended to limit the scope of protection disclosed in the present invention.
[0041] In the description of the embodiments disclosed in the present invention, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0042] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the audio file downloading method based on the Spotify application in the embodiment of the present invention includes:
[0043] 101. When a song download request is detected, a login operation of the Spotify application is performed;
[0044] The professional terms involved in the audio file downloading method based on the Spotify application include but are not limited to:
[0045] Spotify App: refers to the Spotify music streaming platform application used to access and play music content.
[0046] Login action: A user authenticates by entering credentials (such as a username and password) or other verification information (such as an authorization code) to gain access to the Spotify app.
[0047] Spotify API: An application programming interface provided by Spotify that allows developers to access and operate data and services on the Spotify platform through API requests, such as obtaining music information, user data, etc.
[0048] Link media information: Contains relevant information about the song you want to download, such as the song's unique identifier (trackId) and other necessary data.
[0049] trackId: A unique identifier for a song on the Spotify platform, used to identify a specific piece of music.
[0050] gid: A globally unique identifier generated based on trackId, used to uniquely identify a file or resource of a specific song on the Spotify platform.
[0051] Encrypted Files: Encrypt audio files with digital rights management (DRM) technology to prevent unauthorized access and copying.
[0052] Decryption operation: Use a specific key or decryption algorithm to convert the encrypted audio file into an original audio file that can be played or processed.
[0053] CDM technical solution information: Content Decryption Module, a technical solution for decrypting digital content, including generating keys and related information required for decryption.
[0054] pssh value: A specific data structure used to transmit decryption keys and licenses during the process of multimedia content encryption.
[0055] ffmpeg: An open source multimedia processing tool for converting, processing and editing audio and video files.
[0056] Lossless repair operation: Use tools such as ffmpeg to repair audio files to restore possible audio damage or errors.
[0057] ID3 information adding operation: Add or update the metadata in the audio file (such as song title, artist, album information, etc.) to the ID3 format to facilitate the management and identification of the audio file.
[0058] Playlist: A file containing a list of audio or video files used to play media content in a sequence or rule set by the user.
[0059] In this embodiment, the login operation of the Spotify application is performed according to the preset member account information.
[0060] Optionally, the login verification information carried in the song download request is extracted; and the login operation of the Spotify application is performed according to the login verification information to verify the identity of the user.
[0061] 102. When the login operation is successfully performed, obtaining link media information specified by the song download request through the Spotify API authorized by the Spotify application;
[0062] Specifically, when the login operation is successful, the link media information specified by the song download request is obtained through the Spotify API authorized by the Spotify application.
[0063] Optionally, use the access token obtained after logging in to send a request to the Spotify API to obtain song information. Requests can be sent to the appropriate endpoint of the Spotify API using HTTP requests. Typically, the endpoint for obtaining song information may be / tracks / {track_id} or similar, where {track_id} is the identifier of a specific song. In the API request, include the appropriate authorization header so that the Spotify API can verify the legitimacy and authorization of the request. This can be done by adding a Bearer token in the HTTP header. The access token obtained using the OAuth 2.0 authorization mechanism can be used.
[0064] After receiving the response from the API, parse the returned JSON data. This data may include detailed information of the song (such as name, artist, album, link, etc.) and the URL of the media resource.
[0065] Extract the required link media information from the API response. Mainly the media resource links of the target song, which will be used for the actual file download operation in subsequent steps.
[0066] 103. Extracting trackId from the link media information;
[0067] Specifically, the trackId is extracted from the obtained link media information. The trackId is a unique identifier of the song in Spotify. The extracted trackId is converted into a gid for accessing the relevant information of the target song in the subsequent steps.
[0068] 104. Convert the trackId into gid;
[0069] Among them, the trackId in the song download link is converted into gid through a special algorithm. With gid, the song download address and the initial condition pssh value for decrypting the audio file can be obtained through the Spotify API. A specific special algorithm can be generated through authorization information.
[0070] 105. Based on the gid, obtain a target audio file of the target song through the Spotify application.
[0071] Specifically, based on the converted gid, the audio file of the target song is obtained through the Spotify application.
[0072] Optional, see Figure 2 , Figure 2 1 is a schematic diagram of a specific embodiment of step 105 of the method for downloading an audio file based on the Spotify application in an embodiment of the present invention. Step 105 also includes the following specific implementation methods:
[0073] 1051. Obtain a download link corresponding to the trackId based on the gid;
[0074] Specifically, after successfully converting the trackId to a gid, the audio file download device uses the gid as a parameter to request, through the Spotify API, a download link for the audio file corresponding to the gid.
[0075] This request may return one or more possible download links, depending on Spotify's API design and the song's availability.
[0076] 1052. Execute a file download operation according to the download link to obtain an encrypted file;
[0077] Specifically, the audio file downloading device uses the selected download link to initiate a download request via HTTP or other protocols.
[0078] The downloaded files are usually encrypted, as Spotify usually does not directly provide unencrypted audio files to protect its content copyright.
[0079] The application needs to save the downloaded encrypted file to a local or temporary storage location for subsequent decryption.
[0080] 1053. Perform a decryption operation on the encrypted file to obtain a target audio file of the target song.
[0081] Among them, encrypted audio files generally use digital rights management (DRM) technology to protect copyrighted content from unauthorized access.
[0082] Generate a key for decryption based on the preset CDM technical solution information. CDM (Content Decryption Module) is a module used for digital content decryption, providing the relevant information and algorithms required for decryption.
[0083] Use the generated key to decrypt the downloaded encrypted file.
[0084] After the decryption operation is completed, the decrypted audio file of the target song is obtained. This audio file is no longer encrypted and can be played directly or further processed (such as format conversion, lossless repair, etc.).
[0085] In steps 1051-1053, the process of obtaining trackId based on gid and further obtaining the download link realizes the automation and chain operation of the download process. The detailed steps of decrypting the encrypted file ensure the security of the audio file during transmission and storage.
[0086] Specifically, refer to Figure 3 , Figure 3 1053 is a schematic diagram of a specific embodiment of the method for downloading an audio file based on the Spotify application in an embodiment of the present invention. Step 1053 also includes the following specific implementation methods:
[0087] 10531. Generate a key according to the gid and preset cdm technical solution information;
[0088] 10532. Perform a decryption operation on the encrypted file according to the key to obtain a target audio file of the target song.
[0089] In steps 10531-10532, the preset CDM technical solution provides a structured and interoperable method to protect multimedia content. The use of this technical solution can ensure the compatibility of the audio file downloading device of this embodiment with other compatible devices and platforms, thereby increasing the wide applicability of the decryption operation.
[0090] Specifically, refer to Figure 4 , Figure 4 1 is another specific embodiment diagram of step 105 of the audio file downloading method based on the Spotify application in an embodiment of the present invention, and step 105 also includes the following specific implementation methods:
[0091] 1054. Based on the gid, obtain the to-be-processed file of the target song through the Spotify application;
[0092] 1055. Calling a preset ffmpeg program to perform a lossless repair operation and an ID3 information adding operation on the file to be processed, so as to obtain a file to be converted;
[0093] Specifically, the algorithms for lossless repair operations include but are not limited to:
[0094] Spectral analysis and processing: By analyzing the frequency content of the audio signal, it is possible to identify noisy, distorted, or damaged parts. Spectral analysis using algorithms such as Fourier transform (FFT) can convert the audio signal from the time domain to the frequency domain, making it easier to identify and process the problem parts.
[0095] Noise reduction algorithms: Frequency domain filtering, time domain filtering, and adaptive filtering algorithms can effectively reduce or eliminate noise in audio. These algorithms analyze the spectral characteristics of audio signals, identify noise components, and separate them from the original signal, thereby improving audio clarity.
[0096] Sound distortion repair: This is achieved by using de-distortion technology and enhancement algorithms. De-distortion technology usually involves identifying the type of distortion (such as harmonic distortion, intermodulation distortion, etc.), and then applying the corresponding algorithm to restore the original quality of the sound. The enhancement algorithm improves the sound quality by enhancing certain aspects of the audio signal (such as high-frequency components, dynamic range, etc.).
[0097] Broken sound repair: When broken sounds appear in an audio file, the broken parts can be identified and repaired by analyzing the spectral characteristics of the sound signal. Algorithms such as interpolation and resampling are effective methods for processing broken sounds. These algorithms can estimate and reconstruct the broken parts based on known sound signals to maintain the coherence and naturalness of the audio.
[0098] Deep learning methods: For audio restoration tasks, deep learning models can learn features and patterns extracted from large amounts of data and used to predict and repair damaged audio parts. For example, models such as convolutional neural networks (CNNs) and recurrent neural networks (RNNs) have been used in tasks such as audio noise reduction, sound synthesis, and speech recognition. By training these models to process audio data, higher quality lossless restoration operations can be achieved.
[0099] 1056. Call the ffmpeg program to convert the file to be converted into a preset format to obtain the target audio file.
[0100] In steps 1054-1056, damage or quality issues in the audio file can be repaired through lossless repair operations to ensure maximum audio quality. Adding ID3 tag information to the audio file can include metadata such as song name, artist, album name, and release year, which helps to correctly classify and identify the audio. Converting the audio file to be processed into a preset specific format can flexibly adjust the file format, optimize storage and transmission efficiency, provide optimized high-quality audio files, and ensure the compatibility and availability of the file format.
[0101] Optionally, a playlist is generated according to the target audio file. According to the characteristics of the target audio file, a personalized playlist is automatically generated for the user. The target audio file is included in the playlist, and the user can listen to high-quality music based on the music platform of his or her own sequence number.
[0102] Optionally, a specific usage scenario of this method is as follows:
[0103] 1. To download music files from the official Spotify source, you need to log in to your member account first. Only after a successful login can you use the Spotify API.
[0104] 2. Get song media information through Spotify API and add ID3 tags to the downloaded audio files.
[0105] 3. Convert the trackId in the song link into gid through a special algorithm, and then combine gid and Spotify API to obtain the song download link and decrypt the initial condition pssh value.
[0106] 4. Download the audio file through the download link. At this time, the audio file is encrypted and cannot be played.
[0107] 5. Obtain the key for decrypting the audio file through the CDM technical solution, and then decrypt the audio.
[0108] 6. After successfully decrypting the audio, use ffmpeg to losslessly repair the audio and add ID3 tags.
[0109] 7. Finally, use ffmpeg to convert the audio file into a specified format such as MP3 format.
[0110] In an embodiment of the present invention, when a song download request is detected, a login operation of the Spotify application is performed; when the login operation is successfully performed, the link media information specified by the song download request is obtained through the Spotify API authorized by the Spotify application; the trackId is extracted from the link media information; the trackId is converted into a gid; based on the gid, the target audio file of the target song is obtained through the Spotify application. The use of the user's legal authorization information (login credentials and API access) ensures the security of the music download operation and avoids unauthorized downloading. The audio files obtained through Spotify's API are officially authorized, which can guarantee the sound quality and version of the download and avoid quality problems that may exist in unofficial channels.
[0111] Figure 51 is a schematic diagram of the structure of an audio file downloading device based on the Spotify application provided by an embodiment of the present invention. The audio file downloading device 500 based on the Spotify application may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 may be short-term storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the audio file downloading device 500 based on the Spotify application. Furthermore, the processor 510 may be configured to communicate with the storage medium 530 to execute a series of instruction operations in the storage medium 530 on the audio file downloading device 500 based on the Spotify application.
[0112] The audio file downloading device 500 based on the Spotify application may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Serve, Mac OS X, Unix, Linux, Free BSD, etc. It will be appreciated by those skilled in the art that Figure 5 The structure of the audio file downloading device based on the Spotify application shown does not constitute a limitation on the audio file downloading device based on the Spotify application, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0113] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein instructions are stored in the computer, and when the instructions are executed on a computer, the computer executes the steps of the audio file downloading method based on the Spotify application.
[0114] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0115] In addition, although each operation is described in a specific order, this should be understood as requiring such operation to be performed in the specific order shown or in a sequential order, or requiring that all illustrated operations should be performed to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation can also be implemented in multiple implementations individually or in any suitable sub-combination mode.
[0116] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A method for downloading audio files based on Spotify application, characterized in that: The audio file downloading method based on the Spotify application includes: When a song download request is detected, the Spotify app login operation is performed; When the login operation is successfully performed, obtaining the link media information specified by the song download request through the Spotify API authorized by the Spotify application; Extract trackId from the link media information; Convert the trackId to a gid; Based on the gid, a target audio file of a target song is obtained through the Spotify application.
2. The method for downloading audio files based on the Spotify application according to claim 1, characterized in that: The step of obtaining the target audio file of the target song through the Spotify application based on the gid includes: Obtain a download link corresponding to the trackId based on the gid; Execute a file download operation according to the download link to obtain an encrypted file; A decryption operation is performed on the encrypted file to obtain a target audio file of the target song.
3. The method for downloading audio files based on the Spotify application according to claim 2, characterized in that: The step of performing a decryption operation on the encrypted file to obtain a target audio file of the target song comprises: Generate a key according to the gid and preset cdm technical solution information; The encrypted file is decrypted according to the key to obtain the target audio file of the target song.
4. The method for downloading audio files based on the Spotify application according to claim 2, characterized in that: The step of performing a decryption operation on the encrypted file to obtain a target audio file of the target song comprises: A pssh value is generated according to the gid, and a decryption operation is performed on the encrypted file according to the pssh value to obtain a target audio file of the target song.
5. The method for downloading audio files based on the Spotify application according to claim 1, characterized in that: The step of obtaining a target audio file of a target song through the Spotify application based on the gid includes: Based on the gid, obtaining a to-be-processed file of the target song through the Spotify application; Calling a preset ffmpeg program to perform a lossless repair operation and an ID3 information adding operation on the file to be processed, so as to obtain a file to be converted; The ffmpeg program is called to convert the file to be converted into a preset format to obtain the target audio file.
6. The method for downloading audio files based on Spotify application according to claim 1, characterized in that: The steps of performing a login operation of the Spotify application include: Log in to the Spotify app based on the preset membership account information.
7. The method for downloading audio files based on Spotify application according to claim 1, characterized in that: The steps of performing a login operation of the Spotify application include: Extracting the login verification information carried in the song download request; The login operation of the Spotify application is performed according to the login verification information.
8. The method for downloading audio files based on Spotify application according to claim 1, characterized in that: After the step of obtaining the target audio file of the target song through the Spotify application based on the gid, the method further includes: A playlist is generated according to the target audio file.
9. An audio file downloading device based on Spotify application, characterized in that: The audio file downloading device based on the Spotify application includes: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instructions in the memory to enable the audio file downloading device based on the Spotify application to execute the audio file downloading method based on the Spotify application as described in any one of claims 1-8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for downloading an audio file based on the Spotify application as described in any one of claims 1 to 8 is implemented.
