MCPcopy Create free account
hub / github.com/AudDMusic/RedditBot / GetSkipFirstFromLink

Function GetSkipFirstFromLink

main.go:507–551  ·  view source on GitHub ↗
(Url string)

Source from the content-addressed store, hash-verified

505var myRepliesMu = &sync.Mutex{}
506
507func GetSkipFirstFromLink(Url string) int {
508 skip := 0
509 if strings.HasSuffix(Url, ".m3u8") {
510 return skip
511 }
512 u, err := url.Parse(Url)
513 if err == nil {
514 t := u.Query().Get("t")
515 if t == "" {
516 t = u.Query().Get("time_continue")
517 if t == "" {
518 t = u.Query().Get("start")
519 }
520 }
521 if t != "" {
522 t = strings.ToLower(strings.ReplaceAll(t, "s", ""))
523 tInt := 0
524 if strings.Contains(t, "m") {
525 s := strings.Split(t, "m")
526 tsInt, _ := strconv.Atoi(s[1])
527 tInt += tsInt
528 if strings.Contains(s[0], "h") {
529 s := strings.Split(s[0], "h")
530 if tmInt, err := strconv.Atoi(s[1]); !capture(err) {
531 tInt += tmInt * 60
532 }
533 if thInt, err := strconv.Atoi(s[0]); !capture(err) {
534 tInt += thInt * 60 * 60
535 }
536 } else {
537 if tmInt, err := strconv.Atoi(s[0]); !capture(err) {
538 tInt += tmInt * 60
539 }
540 }
541 } else {
542 if tsInt, err := strconv.Atoi(t); !capture(err) {
543 tInt = tsInt
544 }
545 }
546 skip += tInt
547 fmt.Println("skip:", skip)
548 }
549 }
550 return skip
551}
552
553func removeFormatting(response string) string {
554 response = strings.ReplaceAll(response, "**", "*")

Callers 1

HandleQueryMethod · 0.85

Calls 1

captureFunction · 0.85

Tested by

no test coverage detected