<commit_before>package agqr

import (
	"io"
	"net/http"
	"strconv"
	"strings"
	"time"

	"github.com/PuerkitoBio/goquery"
	"github.com/yosida95/timetable"
	"github.com/yosida95/timetable/internal"
	"golang.org/x/net/html/atom"
)

const (
	TIMETABLE_URL = "http://www.agqr.jp/timetable/streaming.php"
)

func parseProgram(col *goquery.Selection, weekday time.Weekday, prev *timetable.Program, now time.Time) (*timetable.Program, error) {
	h, m, err := internal.ParseTimeColonSeparated(col.Find("div.time").Text())
	if err != nil {
		return nil, err
	}
	if 4 >= h {
		weekday = (weekday + 1) % 7
	}

	nextDuration := internal.WaitTimeToNextOA(now, h, m, weekday)
	prog := &timetable.Program{
		Title:  strings.TrimSpace(col.Find("div.title-p").Text()),
		NextOA: now.Add(nextDuration),
	}<commit_msg>provide Program.URL, and Program.MailAddr<commit_after>package agqr

import (
	"io"
	"net/http"
	"strconv"
	"strings"
	"time"

	"github.com/PuerkitoBio/goquery"
	"github.com/yosida95/timetable"
	"github.com/yosida95/timetable/internal"
	"golang.org/x/net/html/atom"
)

const (
	TIMETABLE_URL = "http://www.agqr.jp/timetable/streaming.php"
)

func parseProgram(col *goquery.Selection, weekday time.Weekday, prev *timetable.Program, now time.Time) (*timetable.Program, error) {
	h, m, err := internal.ParseTimeColonSeparated(col.Find("div.time").Text())
	if err != nil {
		return nil, err
	}
	if 4 >= h {
		weekday = (weekday + 1) % 7
	}
	nextDuration := internal.WaitTimeToNextOA(now, h, m, weekday)

	title := col.Find("div.title-p")
	url, _ := title.Find("a").Attr("href")

	prog := &timetable.Program{
		Title:  strings.TrimSpace(title.Text()),
		NextOA: now.Add(nextDuration),

		URL: strings.TrimSpace(url),
	}

	col.Find("div.rp").Children().Each(func(_ int, s *goquery.Selection) {
		switch s.Nodes[0].DataAtom {
		case atom.A:
			href, _ := s.Attr("href")
			href = strings.TrimSpace(href)
			if strings.HasPrefix(href, "mailto:") {
				prog.MailAddr = href[7:]
			}
		}
	})
{'fraction_non_alphanumeric': 0.17290192113245703, 'fraction_numerical': 0.008088978766430738, 'mean_word_length': 4.263297872340425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6557503', 'n_tokens_mistral': 857, 'n_tokens_neox': 775, 'n_words': 134}