<commit_before>package main

import (
	"fmt"
	"os"
)

type qsong struct {
	Title  string
	Album  string
	Artist string
	Length int
	File   string
}

type queue struct {
	// Queue.
	queue []*qsong
	//Current playing song
	np *qsong
	//Current file in use
	CFile int
	//Transcoding status
	transcoding bool
	//Playing status
	playing bool
}

//Create a new queue
func newQueue() *queue {
	return &queue{
		queue:       make([]*qsong, 0),
		CFile:       1,
		np:          nil,
		transcoding: false,
	}
}

//Consumes and returns the first value in the queue
//Precondition: queue has at least one item in it
func (q *queue) consume() *qsong {
	/*
		if len(q.Queue) < 1 {
			return nil, errors.New("Nothing in queue!")
		}
	*/
	s := q.queue[0]
	if len(q.queue) > 1 {
		q.queue = q.queue[1:]
	} else {
		//There has to be a better way of doing this
		q.queue = make([]*qsong, 0)
	}
	if q.CFile == 1 {
		q.CFile = 2
	} else {
		q.CFile = 1
	}
	q.np = s
	return s
}

//Adds a new item to the queue
func (q *queue) add(s *qsong) {
	q.queue = append(q.queue, s)
}

//Transcodes the next appropriate song
func (q *queue) transcodeNext() {
	fmt.Println("Transcoding Song: ", q.queue[0].File)
	q.transcoding = true
	transcode(musicDir + "/" + q.queue[0].File)<commit_msg>Fix to prevent double transcodes<commit_after>package main

import (
	"fmt"
	"os"
)

type qsong struct {
	Title  string
	Album  string
	Artist string
	Length int
	File   string
}

type queue struct {
	// Queue.
	queue []*qsong
	//Current playing song
	np *qsong
	//Current file in use
	CFile int
	//Transcoding status
	transcoding bool
	//Playing status
	playing bool
	//Previously transcoded file -- Used to prevent dupes
	pt string
}

//Create a new queue
func newQueue() *queue {
	return &queue{
		queue:       make([]*qsong, 0),
		CFile:       1,
		np:          nil,
		transcoding: false,
		pt:          "",
	}
}

//Consumes and returns the first value in the queue
//Precondition: queue has at least one item in it
func (q *queue) consume() *qsong {
	/*
		if len(q.Queue) < 1 {
			return nil, errors.New("Nothing in queue!")
		}
	*/
	s := q.queue[0]
	if len(q.queue) > 1 {
		q.queue = q.queue[1:]
	} else {
		//There has to be a better way of doing this
		q.queue = make([]*qsong, 0)
	}
	if q.CFile == 1 {
		q.CFile = 2
	} else {
		q.CFile = 1
	}
	q.np = s
	return s
}

//Adds a new item to the queue
func (q *queue) add(s *qsong) {
	q.queue = append(q.queue, s)
}

//Transcodes the next appropriate song
func (q *queue) transcodeNext() {
	//Need a better way of doing this -- perhaps transfer
	//From a nontranscoded queue to a transcoded queue?
	if q.pt == q.queue[0].File {
		fmt.Println("This song has already been transcoded!")
		return
	}
	q.pt = q.queue[0].File

	fmt.Println("Transcoding Song: ", q.queue[0].File)
	q.transcoding = true
	transcode(musicDir + "/" + q.queue[0].File)
{'fraction_non_alphanumeric': 0.13328656611715187, 'fraction_numerical': 0.009119607155384075, 'mean_word_length': 2.7675033025099074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6906652', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1076, 'n_words': 354}