Skip to content

Commit

Permalink
Merge pull request #18 from kepler471/redo-remove-youtubedl-functiona…
Browse files Browse the repository at this point in the history
…lity

Redo remove youtubedl functionality
  • Loading branch information
kepler471 authored Sep 5, 2023
2 parents db9c4b2 + c8e798b commit fcae059
Show file tree
Hide file tree
Showing 18 changed files with 364 additions and 483 deletions.
30 changes: 0 additions & 30 deletions DashFiles/DASHPlaylist-1.mpd

This file was deleted.

30 changes: 0 additions & 30 deletions DashFiles/DASHPlaylist-2.mpd

This file was deleted.

30 changes: 0 additions & 30 deletions DashFiles/DASHPlaylist-3.mpd

This file was deleted.

39 changes: 0 additions & 39 deletions DashFiles/DASHPlaylist-4.mpd

This file was deleted.

39 changes: 0 additions & 39 deletions DashFiles/DASHPlaylist-5.mpd

This file was deleted.

33 changes: 0 additions & 33 deletions DashFiles/DASHPlaylist-6.mpd

This file was deleted.

30 changes: 0 additions & 30 deletions DashFiles/DASHPlaylist.mpd

This file was deleted.

13 changes: 13 additions & 0 deletions dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ type BaseUrl struct {
Data string `xml:",chardata"`
}

type DashVideo int

const (
K_600 DashVideo = iota
M_1_2
M_2_4
M_4_8
R_240
R_360
R_480
R_720
)

// decode returns all variations of BaseUrl in a DASHPlaylist.mpd file.
func decode(mpd io.Reader) []string {
dec := xml.NewDecoder(mpd)
Expand Down
98 changes: 47 additions & 51 deletions dash_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"reflect"
"strings"
"testing"
)

func Test_decode(t *testing.T) {
dashDir := "./DashFiles/"
fs, _ := ioutil.ReadDir(dashDir)
fs, _ := os.ReadDir(dashDir)
for _, f := range fs {
if strings.HasSuffix(f.Name(), ".mpd") {
mpd, _ := os.Open(dashDir + f.Name())
Expand All @@ -23,50 +19,50 @@ func Test_decode(t *testing.T) {
}
}

func Test_scrapeReddit(t *testing.T) {
Url, _ := url.Parse("https://www.reddit.com/domain/v.redd.it/")
j, _ := fetchJson(Url)
var result interface{}
json.Unmarshal(j, &result)
m := result.(map[string]interface{})
// func Test_scrapeReddit(t *testing.T) {
// Url, _ := url.Parse("https://www.reddit.com/domain/v.redd.it/")
// j, _ := fetchJson(Url)
// var result interface{}
// json.Unmarshal(j, &result)
// m := result.(map[string]interface{})

var stack []string
var walk func(value reflect.Value)
walk = func(v reflect.Value) {
if v.String() == "dash_url" {
fmt.Printf("Visiting %v\n", v)
}
for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
v = v.Elem()
}
switch v.Kind() {
case reflect.Array, reflect.Slice:
for i := 0; i < v.Len(); i++ {
walk(v.Index(i))
}
case reflect.Map:
for _, k := range v.MapKeys() {
//if k.String() == "dash_url" {
if k.String() == "url_overridden_by_dest" {
stack = append(stack, fmt.Sprintf("%v", v.MapIndex(k)))
return
}
if k.String() != "secure_media" {
walk(v.MapIndex(k))
}
}
}
}
walk(reflect.ValueOf(m))
ch := make(chan struct{})
for _, u := range stack {
go func(mpd string) {
resp, _ := fetch(mpd)
fmt.Println(mpd, decode(resp.Body))
ch <- struct{}{}
}(u + "/DASHPlaylist.mpd")
}
for range stack {
<-ch
}
}
// var stack []string
// var walk func(value reflect.Value)
// walk = func(v reflect.Value) {
// if v.String() == "dash_url" {
// fmt.Printf("Visiting %v\n", v)
// }
// for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
// v = v.Elem()
// }
// switch v.Kind() {
// case reflect.Array, reflect.Slice:
// for i := 0; i < v.Len(); i++ {
// walk(v.Index(i))
// }
// case reflect.Map:
// for _, k := range v.MapKeys() {
// //if k.String() == "dash_url" {
// if k.String() == "url_overridden_by_dest" {
// stack = append(stack, fmt.Sprintf("%v", v.MapIndex(k)))
// return
// }
// if k.String() != "secure_media" {
// walk(v.MapIndex(k))
// }
// }
// }
// }
// walk(reflect.ValueOf(m))
// ch := make(chan struct{})
// for _, u := range stack {
// go func(mpd string) {
// resp, _ := fetch(mpd)
// fmt.Println(mpd, decode(resp.Body))
// ch <- struct{}{}
// }(u + "/DASHPlaylist.mpd")
// }
// for range stack {
// <-ch
// }
// }
Loading

0 comments on commit fcae059

Please sign in to comment.