package com.wasu.cs.model;

import com.wasu.base.privateconfig.Config;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;

public class DemandSeries implements Serializable {
	private static final long serialVersionUID = 4534010583636177879L;
	/*  "datetime": "2014-01-27",
      "episode": 1,
      "itemId": 309921,
      "playUrls": [
          "28271C8C8F9DCA7DD4EE83F2B7EA12B221B1C853DF4ACA6B9EA15403986F8783DAA19B4CAD6229AE44C62097EAA617C085E34F9DCC581EA1D173A8B84F6B61786C0F5EB9FBAA4EA00EFCD6D473832ADE6DD4F0D411FD9A9CB06D48E4E8971043FB8AE1DAC97F580351C6B3652A68FC76CAE3A7CB35501D36E0DD54BB0A0FE65E0EEC88A0708A900944C33BC784BD726A6496F819CC2834136CE957FD89DD95CFB70675AF3B13640C0E685D89898067739C4559C8028609DF1E8ACCCAACF0539D"
      ],
      "title": "刘海砍樵_1"*/
	private String itemId;//子集ID
	private String title;//子集标题 
	private int episode;//第几集
	private String datetime;//时间信息，数据格式初定“yyyy-mm-dd”
	private String duration;

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	private int isTodayUpdate;//是否是当天上新的，1是，0否
	private ArrayList<String> playUrls = new ArrayList<String>();//播放地址集合,目前只有一个播放串
    private String picUrl;
	private String ottItemFee;
	private String ottVodId;
	private int previewTime;//预览时间,单位秒

    public DemandSeries(JSONObject jsondata) {
		itemId = jsondata.optString("itemId");
		title = jsondata.optString("title");
		episode = jsondata.optInt("episode");
		datetime = jsondata.optString("datetime");
		duration=jsondata.optString("duration");
        picUrl = jsondata.optString("picUrl");
        isTodayUpdate=jsondata.optInt("isTodayUpdate");
		ottVodId=jsondata.optString("ottVodId");
		ottItemFee=jsondata.optString("ottItemFee");
		JSONArray tempArray=jsondata.optJSONArray("playUrls");
		int len=tempArray.length();
		playUrls.clear();
		for(int i=0;i<len;i++){
			try {
				playUrls.add(tempArray.getString(i));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
		previewTime = jsondata.optInt("previewtime", Config.MAX_PREVIEW_MINUTES * 60);
	}

	public DemandSeries() {
		// TODO Auto-generated constructor stub
	}

	public ArrayList<String> getPlayUrls() {
		return playUrls;
	}

	public void setPlayUrls(ArrayList<String> playUrls) {
		this.playUrls = playUrls;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getOttVodId() {
		return ottVodId;
	}

	public void setOttVodId(String ottVodId) {
		this.ottVodId = ottVodId;
	}

	public void setEpisode(int episode) {
		this.episode = episode;
	}

	public void setDatetime(String datetime) {
		this.datetime = datetime;
	}

	public void setIsTodayUpdate(int isTodayUpdate) {
		this.isTodayUpdate = isTodayUpdate;
	}

	public void setPicUrl(String picUrl) {
		this.picUrl = picUrl;
	}

	public void setPreviewTime(int previewTime) {
		this.previewTime = previewTime;
	}
	public String getOttItemFee() {
		return ottItemFee;
	}

	public void setOttItemFee(String ottItemFee) {
		this.ottItemFee = ottItemFee;
	}

	public String getItemId() {
		return itemId;
	}
	public String getTitle() {
		return title;
	}
	public int getEpisode() {
		return episode;
	}
	public String getDatetime() {
		return datetime;
	}
	public String getEncryUrl(){
		return playUrls.size()>0?playUrls.get(0):"";
	}
	public int getIsTodayUpdate(){
		return isTodayUpdate;
	}
    public String getPicUrl() {
        return picUrl;
    }

	public int getPreviewTime() {
		return previewTime;
	}
}
