Coder Social home page Coder Social logo

163keymarker's Introduction

163 Key Marker

Go Report Card

A simple tool for adding id3v2 tag and 163 key tag to a music file.

Some examples:

  • Add 163 key, id3v2 tag and cover to a music file:
package main

import (
	"net/http"
	"os"

	"github.com/XiaoMengXinX/163KeyMarker"
	"github.com/XiaoMengXinX/Music163Api-Go/api"
	"github.com/XiaoMengXinX/Music163Api-Go/utils"
)

func main() {
	data := utils.RequestData{}

	songDetail, _ := api.GetSongDetail(data, []int{1965687934})
	songUrlData, _ := api.GetSongURL(data, api.SongURLConfig{Ids: []int{1965687934}})

	pic, _ := http.Get(songDetail.Songs[0].Al.PicUrl)

	mark := marker.CreateMarker(songDetail.Songs[0], songUrlData.Data[0])

	file, _ := os.Open("1965687934.flac")
	defer file.Close()

	err := marker.AddMusicID3V2(file, pic.Body, mark)
	if err != nil {
		panic(err)
	}
}

The output file will look like:

Snipaste_2022-10-30_21-30-41

  • Parse the embedded 163 key tag from a music file:
package main

import (
	"encoding/json"
	"fmt"
	"os"

	"github.com/XiaoMengXinX/163KeyMarker"
)

func main() {
	file, _ := os.Open("1965687934.flac")
	defer file.Close()

	mark, err := marker.Parse163Key(file)
	if err != nil {
		panic(err)
	}

	markerJson, _ := json.MarshalIndent(mark, "", "  ")

	fmt.Println(string(markerJson))
}

Output:

{
  "musicId": 1965687934,
  "musicName": "洛天依印象曲·华风夏韵",
  "artist": [
    [
      "Tino.S3",
      12002114
    ]
  ],
  "albumId": 148413696,
  "album": "洛天依印象曲·华风夏韵",
  "albumPicDocId": "109951167697837238",
  "albumPic": "https://p1.music.126.net/1oZ0ftxNE5DGzwvO97bfLA==/109951167697837238.jpg",
  "bitrate": 320000,
  "mp3DocId": "7ee41abd08e7e829b41dfd7b0689a256",
  "duration": 207158,
  "mvId": 0,
  "alias": [],
  "format": "mp3"
}
  • Create a 163 key string from marker data:
package main

import (
	"fmt"

	marker "github.com/XiaoMengXinX/163KeyMarker"
)

func main() {
	data := marker.MarkerData{
		MusicId:   1965687934,
		MusicName: "洛天依印象曲·华风夏韵",
	}
	mark := marker.Create163KeyStr(data)
	fmt.Println(mark)
}

Output:

163 key(Don't modify):L64FU3W4YxX3ZFTmbZ+8/ZedOKM0To3lAHr1q3yMEARRJ+Dh+02XUDlnBUo9rPC7jWKxG/Gy7ZpnrH1ckjYKYK+JIykH3KOIxteIZFAWNkWJfR2PtFQs5GIQ921WIUnZai33f5lhpDb3hPlVWOzxPRg136s014agaLb9aILz/o7nRBknv1hFWdGpvpMn3vk2vkQy6ExluHEbeU7tdPZ/ENE44YGEWHTu/DkkFJkQ1OrPmcTkHsEAQqBMQ0pBox7lh3Nh3Iib5LNuGr3vENJ21SMwCerf0QUQzSobspcWLzc=
  • Decrypt the 163 key string:
package main

import (
	"fmt"

	"github.com/XiaoMengXinX/163KeyMarker"
)

func main() {
	encrypted := "163 key(Don't modify):L64FU3W4YxX3ZFTmbZ+8/ZedOKM0To3lAHr1q3yMEARRJ+Dh+02XUDlnBUo9rPC7jWKxG/Gy7ZpnrH1ckjYKYK+JIykH3KOIxteIZFAWNkXQFFl4yALfP5TWmM7sYeBMRLPdbSFzK6VaPrsN9FTCJ8IAo1F/rUBzF2OnlxZrQuwSQXmcPESzQbbgOeDv9V58u+0v3r/fpEQkFcFeIjsR1kK6EGutL/WX6tWp2t6Zfx3aIJLt/ZOLKeUhlvYGxTtNDWqaqg19i0CKZ4Lpay5Ha1GDqBu9VZ7ZPKo2ofJ0cLaPuQqEVjESFiQQPdhrj6hMSFo+rZpI4WKkZ6xwR6vQHmXnlDXh3NzT/vifHNoTBCiZM3PGicKQQKq4KsRwU1Gd2L12na0AeVuxkhHpKAIYo0/eOOrDfcOqh+d2xkdrWEOCGx06KlZTOOJk1X6lQjNUbp5G4VmKySCPxkPdCf/mUbAns8+yfb2WJgxUeJ40glqR8v0JixTjqN7ssZ1yegpkn1I8rS+tkrpbegWZeTOf7Kywi4SypxwQOc9S/+QUi9s="
	decrypted := marker.Decrypt163key(encrypted)
	fmt.Println(decrypted)
}

Output:

music:{"musicId": 1965687934, "musicName": "洛天依印象曲·华风夏韵", "artist":[["Tino.S3", 12002114]], "albumId": 148413696, "album": "洛天依印象曲·华风夏韵", "albumPicDocId": "109951167697837238", "albumPic": "https://p1.music.126.net/1oZ0ftxNE5DGzwvO97bfLA==/109951167697837238.jpg", "bitrate": 320000, "mp3DocId": "7ee41abd08e7e829b41dfd7b0689a256", "duration": 207158, "mvId": 0, "alias":[], "format": "mp3"}

163keymarker's People

Contributors

xiaomengxinx 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.