fix: blocked Pop-up for Paid Songs in Playlist。

This commit is contained in:
tofuliang 2023-09-23 05:18:19 +08:00
parent 7c7769c13e
commit b9905f0c8e
4 changed files with 56 additions and 14 deletions

3
app.go
View File

@ -5,6 +5,7 @@ import (
"log"
"os"
"os/signal"
"runtime/debug"
"syscall"
"github.com/cnsilvan/UnblockNeteaseMusic/config"
@ -23,7 +24,7 @@ func main() {
//fmt.Println(version.AppVersion())
defer func() {
if r := recover(); r != nil {
log.Println("Recover panic : ", r)
log.Println("Recover panic : "+"\n"+string(debug.Stack()), r)
restoreHosts()
}
}()

View File

@ -320,9 +320,8 @@ func localVIP(netease *Netease) bool {
expireTime += 3162240000000
info.(common.MapType)["data"].(common.MapType)["redVipLevel"] = 7
info.(common.MapType)["data"].(common.MapType)["redVipAnnualCount"] = 1
info.(common.MapType)["data"].(common.MapType)["musicPackage"].(common.MapType)["expireTime"] = expireTime
info.(common.MapType)["data"].(common.MapType)["musicPackage"].(common.MapType)["vipCode"] = 230
info.(common.MapType)["data"].(common.MapType)["associator"].(common.MapType)["expireTime"] = expireTime
info.(common.MapType)["data"].(common.MapType)["musicPackage"] = &common.MapType{"expireTime": expireTime, "vipCode": 230}
info.(common.MapType)["data"].(common.MapType)["associator"] = &common.MapType{"expireTime": expireTime}
}
return modified
}
@ -631,24 +630,64 @@ func processSliceJson(jsonSlice common.SliceType) bool {
}
func processMapJson(jsonMap common.MapType) bool {
needModify := false
if utils.Exists([]string{"st", "subp", "pl", "dl"}, jsonMap) {
if v, _ := jsonMap["st"]; v.(json.Number).String() != "0" {
if utils.Exists([]string{"st", "subp", "pl", "dl", "chargeType", "cannotListenReason", "paidBigBang", "resConsumable", "cp", "fee", "payed", "fl", "flLevel", "plLevel"}, jsonMap) {
if v, _ := jsonMap["st"]; v != nil && v.(json.Number).String() != "0" {
// open gray song
jsonMap["st"] = 0
needModify = true
}
if v, _ := jsonMap["subp"]; v.(json.Number).String() != "1" {
if v, _ := jsonMap["subp"]; v != nil && v.(json.Number).String() != "1" {
jsonMap["subp"] = 1
needModify = true
}
if v, _ := jsonMap["pl"]; v.(json.Number).String() == "0" {
if v, _ := jsonMap["pl"]; v != nil && v.(json.Number).String() == "0" {
jsonMap["pl"] = 320000
needModify = true
}
if v, _ := jsonMap["dl"]; v.(json.Number).String() == "0" {
if v, _ := jsonMap["dl"]; v != nil && v.(json.Number).String() == "0" {
jsonMap["dl"] = 320000
needModify = true
}
if v, _ := jsonMap["chargeType"]; v != nil && v.(json.Number).String() == "1" {
jsonMap["chargeType"] = 0
needModify = true
}
if v, _ := jsonMap["paidBigBang"]; v != nil {
jsonMap["paidBigBang"] = true
needModify = true
}
if v, _ := jsonMap["resConsumable"]; v != nil {
jsonMap["resConsumable"] = false
needModify = true
}
if v, _ := jsonMap["cannotListenReason"]; v != nil {
jsonMap["cannotListenReason"] = nil
needModify = true
}
if v, _ := jsonMap["cp"]; v != nil && v.(json.Number).String() == "0" {
jsonMap["cp"] = 1
needModify = true
}
//if v, _ := jsonMap["fee"]; v != nil && v.(json.Number).String() == "1" {
// jsonMap["fee"] = 8
// needModify = true
//}
if v, _ := jsonMap["fl"]; v != nil && v.(json.Number).String() == "0" {
jsonMap["fl"] = 320000
needModify = true
}
if v, _ := jsonMap["flLevel"]; v != nil && v == "none" {
jsonMap["flLevel"] = "exhigh"
needModify = true
}
if v, _ := jsonMap["plLevel"]; v != nil && v == "none" {
jsonMap["plLevel"] = "exhigh"
needModify = true
}
if v, _ := jsonMap["payed"]; v != nil {
jsonMap["payed"] = 1
needModify = true
}
}
for _, value := range jsonMap {
switch value.(type) {

View File

@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"runtime"
"runtime/debug"
"strconv"
"strings"
"time"
@ -54,7 +55,7 @@ func InitProxy() {
func (h *HttpHandler) ServeHTTP(resp http.ResponseWriter, request *http.Request) {
defer func() {
if r := recover(); r != nil {
log.Println("Recover panic : ", r)
log.Println("Recover panic : "+"\n"+string(debug.Stack()), r)
}
}()
//printMemStats()

View File

@ -21,6 +21,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"runtime/debug"
"sort"
"strings"
@ -86,7 +87,7 @@ func ParseJsonV4(reader io.Reader, dest interface{}) error {
func PanicWrapper(f func()) {
defer func() {
if r := recover(); r != nil {
log.Println("Recover panic : ", r)
log.Println("Recover panic : "+"\n"+string(debug.Stack()), r)
}
}()
f()
@ -105,11 +106,11 @@ func ToJson(object interface{}) string {
}
func Exists(keys []string, h map[string]interface{}) bool {
for _, key := range keys {
if !Exist(key, h) {
return false
if Exist(key, h) {
return true
}
}
return true
return false
}
func Exist(key string, h map[string]interface{}) bool {
_, ok := h[key]