#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
 Copyright (C) 2004 jan gerber <j@reboot.fm>

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Library General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'''

# 1 min pro tag liegt ja nahe
# bei einer 90 min sendung
# dies hier haette noch den vorteil
# dass zu beginn viel begruesst
# und zum schluss viel verabschiedet wuerde
# und es ist mathematisch recht huebsch

import sys
import time
import datetime
# installed by hand right now. might put it in deb package. python-dateutil
from dateutil.parser import *
from dateutil.relativedelta import *



def reboot_replay_recut()
	file_time_format="%Y-%m-%d_%H.%M.%S.ogg"
	start_date=parse("20040201T000000")
	days=90
	samples=44100
	hours_per_day=18
	day_in_seconds=60
	total_length_of_cutup=days*60 # 90minutes
	length_of_one_hour=float(day_in_seconds)/hours_per_day
	
	increment = (float(3600)/days)/hours_per_day-(float(1)/day_in_seconds)
	print increment
	print length_of_one_hour
	day=0
	while day<days:
		hour=0
		while hour<24:
			if hour<6 or hour>=12:
				sec_start = (day * 18 + hour) * increment
				sec_end = sec_start + length_of_one_hour
				#to date
				begin=start_date+relativedelta(days=day,hours=hour,seconds=sec_start)
				end=start_date+relativedelta(days=day,hours=hour,seconds=sec_end)
				output_filename=(start_date+relativedelta(days=day,hours=hour,seconds=sec_start)).strftime("%H/%H.%M.%S_%Y-%m-%d")
				get_part_of_oggstream(begin.timetuple(),end.timetuple(),output_filename):
			hour +=1
		day +=1
	# der 90. tag wird natuerlich erst 6 std haben
