Example #1
0
def record(args):
  base_path = util.parent_path(__file__)
  logging.debug("Base binary path: %s" % base_path)
  file_uuid = uuid.uuid4()
  tmp_flv = os.path.join(base_path, ".".join([str(file_uuid), "flv"]))
  tmp_mp4 = os.path.join(base_path, ".".join([str(file_uuid), "mp4"]))

  # Define output mp4 file name.
  if args.output is not None:
    output_mp4 = args.output
  else:
    output_mp4 = tmp_mp4
  logging.debug("mp4 file name is %s" % output_mp4)

  # Define recording length.
  length = args.length
  logging.debug("showtime length is %s" % length)

  agqr_url = args.agqr_streaming_url

  util.recording_util(agqr_url, tmp_flv, output_mp4, length)
Example #2
0
def timer(args):
  # Define json file
  base_path = util.parent_path(__file__)
  logging.debug("Base binary path: %s" % base_path)

  if args.json is not None:
    programs = args.json
  else:
    programs = os.path.join(base_path, "programs.json")

  if not os.path.exists(programs):
    raise exception.JsonFileError(programs)

  target_program = check_schedule.check_target(programs)
  if target_program is None:
    raise exception.TimerScheduleIncorrect()

  today = datetime.datetime.now().strftime("%Y%m%d")

  radio_path = target_program["path"]
  json_title = "_".join([target_program["title"], today])

  file_uuid = uuid.uuid4()
  tmp_flv = os.path.join(base_path, ".".join([str(file_uuid), "flv"]))

  # Define output mp4 file name.
  output_mp4 = os.path.join(radio_path, ".".join([json_title, "mp4"]))
  logging.debug("mp4 file name is %s" % output_mp4)

  # Define recording length.
  length = target_program["length"]
  logging.debug("showtime length is %s" % length)

  agqr_url = args.agqr_streaming_url

  util.recording_util(agqr_url, tmp_flv, output_mp4, length)