Skip to content

Commit

Permalink
remove dev logs
Browse files Browse the repository at this point in the history
  • Loading branch information
imthaghost committed Jan 11, 2024
1 parent b5118e4 commit 90805a7
Show file tree
Hide file tree
Showing 401 changed files with 31,554 additions and 8,294 deletions.
1 change: 1 addition & 0 deletions pkg/soundcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func GetClientID(data []byte) string {
if err != nil {
log.Fatalln(err)
}

var re = regexp.MustCompile(`client_id:"(.+)",env`) // pattern for finding encrypted string ID
clientString := re.FindString(string(body)) // stream URL
var ree = regexp.MustCompile(`"([^"].*?)"`)
Expand Down
6 changes: 1 addition & 5 deletions pkg/soundcloud/get_client_id.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package soundcloud

import "log"

// Unfortunately, SoundCloud does not inject the client ID into the page source unless the request is made from a browser. ( Javascript is enabled )
// This is a workaround to get the client ID from the JS file that is injected into the page source.

Expand All @@ -10,13 +8,11 @@ func (s *Soundcloud) GetClientID() (string, error) {

// this is the JS file that is injected into the page source
// this can always change at some point, so we have to keep an eye on it
resp, err := s.Client.Get("https://a-v2.sndcdn.com/assets/2-1475fa5a.js")
_, err := s.Client.Get("https://a-v2.sndcdn.com/assets/2-1475fa5a.js")
if err != nil {
return "", err
}

log.Print(resp)

// return hardcoded client ID for now
return "nUB9ZvnjRiqKF43CkKf3iu69D8bboyKY", nil
}
5 changes: 5 additions & 0 deletions pkg/soundcloud/get_random_song_url.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package soundcloud

func (s *Soundcloud) GetRandomSongUrl() (string, error) {
return "", nil
}
11 changes: 1 addition & 10 deletions pkg/soundcloud/get_stream_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package soundcloud
import (
"fmt"
"golang.org/x/net/html"
"log"
"strings"
)

Expand All @@ -27,22 +26,14 @@ func (s *Soundcloud) ConstructStreamURL(doc *html.Node) (string, error) {
if err != nil {
return "", err
}
log.Println("Track Auth: ", trackAuth)
log.Println("Client ID: ", clientID)
log.Println("HLS Stream URL: ", hlsStreamURL)


trackID, streamToken, err := getTrackInfo(hlsStreamURL)

// construct stream url
baseURL := "https://api-v2.soundcloud.com/media/soundcloud:tracks:%s/%s/stream/hls?client_id=%s&track_authorization=%s"

streamURL := fmt.Sprintf(baseURL, trackID, streamToken, clientID, trackAuth)

log.Println("Track ID: ", trackID)
log.Println("Stream Token: ", streamToken)

log.Println("Stream URL: ", streamURL)

return streamURL, nil
}

Expand Down
11 changes: 1 addition & 10 deletions pkg/soundcloud/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ func ExtractSong(url string) {
log.Println(err)
}

//body, _ := io.ReadAll(resp.Body)
//log.Println(string(body))

// parse html
doc, err := htmlquery.Parse(resp.Body)
if err != nil {
Expand All @@ -46,22 +43,16 @@ func ExtractSong(url string) {
log.Println(err)
}

log.Println(streamURL)

songName, err := soundcloud.GetTitle(doc)
if err != nil {
log.Println(err)
}

log.Println(songName)

artwork, err := soundcloud.GetArtwork(doc)
if err != nil {
log.Println(err)
}

log.Println(artwork)

// Get the response from the URL
streamResp, err := http.Get(streamURL)
if err != nil {
Expand Down Expand Up @@ -93,7 +84,7 @@ func ExtractSong(url string) {
if err != nil {
log.Println(err)
}

// set cover image for mp3 file
// TODO: put this code somewhere so that the image gets set at the same time as the song data is being written for smoother transition
mp3.SetCoverImage(songName+".mp3", image)
}
3 changes: 3 additions & 0 deletions vendor/github.com/PuerkitoBio/goquery/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/github.com/PuerkitoBio/goquery/utilities.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions vendor/github.com/fatih/color/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 90805a7

Please sign in to comment.