Package net.sf.xtvdclient.xtvd.datatypes

Examples of net.sf.xtvdclient.xtvd.datatypes.Xtvd


                SCHEDULESDIRECT_SERVICE);
        Calendar start = startDate.getCalendar();
        Calendar end = (Calendar) startDate.getCalendar().clone();
        end.add(Calendar.DAY_OF_MONTH, dateCount);

        final Xtvd xtvd = new Xtvd();
        soapRequest.getData(start, end, xtvd);

        monitor.setMessage(mLocalizer.msg("parsing", "Parsing SchedulesDirect Data"));

        Collection<Schedule> schedules = xtvd.getSchedules();

        HashMap<String, Channel> channelMap = new HashMap<String, Channel>();
        for (Channel ch : channelArr) {
          channelMap.put(ch.getId(), ch);
        }

        mChannelMap = new HashMap<Channel, Map<devplugin.Date, MutableChannelDayProgram>>();
        for (Schedule schedule : schedules) {
          Channel ch = channelMap.get(Integer.toString(schedule.getStation()));
          if (ch != null) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(schedule.getTime().getLocalDate());
            devplugin.Date programDate = new Date(cal);
            MutableChannelDayProgram chDayProgram = getMutableDayProgram(ch, programDate);

            MutableProgram prog = new MutableProgram(ch, programDate, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
            net.sf.xtvdclient.xtvd.datatypes.Program xtvdProgram = xtvd.getPrograms().get(schedule.getProgram());

            int info = 0;
            if (schedule.getCloseCaptioned()) {
              info |= Program.INFO_SUBTITLE_FOR_AURALLY_HANDICAPPED;
            }
            if (schedule.getStereo()) {
              info |= Program.INFO_AUDIO_STEREO;
            }
            if (schedule.getSubtitled()) {
              info |= Program.INFO_ORIGINAL_WITH_SUBTITLE;
            }
            if (schedule.getHdtv()) {
              info |= Program.INFO_VISION_HD;
            }
            if (xtvdProgram.getColorCode() != null) {
              String code = xtvdProgram.getColorCode().toLowerCase();
              if (code.contains("black") || code.contains("bw")) {
                info |= Program.INFO_VISION_BLACK_AND_WHITE;
              }
              else if (!code.equalsIgnoreCase("Color and B & W")) {
                mLog.warning("Unknown color code: " + xtvdProgram.getColorCode());
              }
            }

            prog.setInfo(info);

            prog.setTitle(xtvdProgram.getTitle());

            if (xtvdProgram.getSyndicatedEpisodeNumber() != null) {
              try {
                prog.setIntField(ProgramFieldType.EPISODE_NUMBER_TYPE, Integer.parseInt(xtvdProgram.getSyndicatedEpisodeNumber()));
              } catch (NumberFormatException e) {
                // ignore, the syndicated episode number may also be an arbitrary string
              }
            }

            if (xtvdProgram.getSubtitle() != null) {
              prog.setTextField(ProgramFieldType.EPISODE_TYPE, xtvdProgram.getSubtitle());
            }

            if (xtvdProgram.getYear() != null) {
              try {
                prog.setIntField(ProgramFieldType.PRODUCTION_YEAR_TYPE, Integer.parseInt(xtvdProgram.getYear()));
                // year is only set for movies
                setMovieType(prog);
              } catch (NumberFormatException e) {
                e.printStackTrace();
              }
            } else if (xtvdProgram.getOriginalAirDate() != null) {
              Calendar aircal = Calendar.getInstance();
              java.util.Date date = xtvdProgram.getOriginalAirDate().getDate();
              aircal.setTime(date);
              prog.setIntField(ProgramFieldType.PRODUCTION_YEAR_TYPE, aircal.get(Calendar.YEAR));
              String repetition = new SimpleDateFormat().format(date);
              if (repetition.endsWith("00:00")) {
                repetition = repetition.substring(0, repetition.length() - "00:00".length()).trim();
              }
              prog.setTextField(ProgramFieldType.REPETITION_OF_TYPE, repetition);
            }

            StringBuilder desc = new StringBuilder();
            if (xtvdProgram.getDescription() != null) {
              desc.append(xtvdProgram.getDescription()).append('\n');
            }
            if (xtvdProgram.getStarRating() != null) {
              int rating = parseStarRating(xtvdProgram.getStarRating());
              if (rating >= 0) {
                prog.setIntField(ProgramFieldType.RATING_TYPE, rating);
              }
              setMovieType(prog);
            }
            if (xtvdProgram.getMpaaRating() != null) {
              String rating = xtvdProgram.getMpaaRating().toString();
              prog.setTextField(ProgramFieldType.AGE_RATING_TYPE, rating);
              int ageLimit = ProgramUtilities.getAgeLimit(rating);
              if (ageLimit >= 0) {
                prog.setIntField(ProgramFieldType.AGE_LIMIT_TYPE, ageLimit);
              }
              setMovieType(prog);
            }
            if (schedule.getTvRating() != null) {
              String rating = schedule.getTvRating().toString();
              String ratingString = prog.getTextField(ProgramFieldType.AGE_RATING_TYPE);
              if (ratingString != null) {
                ratingString = ratingString + ", " + rating;
              }
              else {
                ratingString = rating;
              }
              prog.setTextField(ProgramFieldType.AGE_RATING_TYPE, ratingString);
              int ageLimit = ProgramUtilities.getAgeLimit(rating);
              if (ageLimit >= 0) {
                prog.setIntField(ProgramFieldType.AGE_LIMIT_TYPE, ageLimit);
              }
            }
            if (xtvdProgram.getAdvisories() != null && !xtvdProgram.getAdvisories().isEmpty()) {
              StringBuilder advBuilder = new StringBuilder();

              for (MovieAdvisories advisory : xtvdProgram.getAdvisories()) {
                if (advBuilder.length() > 0) {
                  advBuilder.append(", ");
                }
                advBuilder.append(advisory.toString());
              }
              desc.append("\nAdvisories: ").append(advBuilder.toString());
            }

            if (xtvdProgram.getRunTime() != null) {
              try {
                int length = Integer.parseInt(xtvdProgram.getRunTime().getHours())*60 + Integer.parseInt(xtvdProgram.getRunTime().getMinutes());
                prog.setIntField(ProgramFieldType.NET_PLAYING_TIME_TYPE, length);
              } catch (NumberFormatException e) {
                e.printStackTrace();
              }
            }
            /*
            if (xtvdProgram.getSeries() != null) {
              desc.append("\nSeries : ").append(xtvdProgram.getSeries());
            }
            if (xtvdProgram.getShowType()!= null) {
              desc.append("\nShowType : ").append(xtvdProgram.getShowType());
            } */

            if (schedule.getPart() != null) {
              final Part part = schedule.getPart();
              desc.append("\nPart " + part.getNumber() + " of " + part.getTotal());
            }
            if (schedule.getRepeat() && xtvdProgram.getOriginalAirDate() == null) {
              prog.setTextField(ProgramFieldType.REPETITION_OF_TYPE, "unknown previous program");
            }


            Crew crew = xtvd.getProductionCrew().get(xtvdProgram.getId());
            if (crew != null) {
              StringBuilder actors = new StringBuilder();
              StringBuilder director = new StringBuilder();
              StringBuilder host = new StringBuilder();
              StringBuilder producer = new StringBuilder();
              StringBuilder writer = new StringBuilder();
              StringBuilder additional = new StringBuilder();

              for (CrewMember member : crew.getMember()) {
                final String role = member.getRole();
                if ("Actor".equalsIgnoreCase(role) || "Guest Star".equals(role)) {
                  appendPerson(actors, member);
                } else if ("Director".equalsIgnoreCase(role)) {
                  appendPerson(director, member);
                } else if ("Host".equalsIgnoreCase(role) || "Anchor".equalsIgnoreCase(role)) {
                  appendPerson(host, member);
                } else if (role.toLowerCase().contains("producer")) {
                  appendPerson(producer, member);
                } else if ("Writer".equalsIgnoreCase(role)) {
                  appendPerson(writer, member);
                } else if (role.toLowerCase().contains("guest")) {
                  appendPerson(additional, member);
                }
                else if ("Narrator".equalsIgnoreCase(role)) {
                  appendPersonWithRole(additional, member);
                }
                else {
                  appendPersonWithRole(additional, member);
                  if (!role.equalsIgnoreCase("judge")) {
                    mLog.warning("Unknown crew member role: " + role);
                  }
                }
              }
              if (actors.length() > 0) {
                prog.setTextField(ProgramFieldType.ACTOR_LIST_TYPE, actors.toString());
              }
              if (director.length() > 0) {
                prog.setTextField(ProgramFieldType.DIRECTOR_TYPE, director.toString());
              }
              if (host.length() > 0) {
                prog.setTextField(ProgramFieldType.MODERATION_TYPE, host.toString());
              }
              if (producer.length() > 0) {
                prog.setTextField(ProgramFieldType.PRODUCER_TYPE, producer.toString());
              }
              if (writer.length() > 0) {
                prog.setTextField(ProgramFieldType.SCRIPT_TYPE, writer.toString());
              }
              if (additional.length() > 0) {
                prog.setTextField(ProgramFieldType.ADDITIONAL_PERSONS_TYPE, additional.toString());
              }
            }

            ProgramGenre programGenre = xtvd.getGenres().get( xtvdProgram.getId() );
            if (programGenre != null) {
              StringBuilder genreStr = new StringBuilder();
              for (Genre genre : programGenre.getGenres()) {
                if (genreStr.length() > 0) {
                  genreStr.append(", ");
View Full Code Here


              SCHEDULESDIRECT_SERVICE);
      Calendar start = Calendar.getInstance();
      Calendar end = Calendar.getInstance();
      end.add(Calendar.DAY_OF_MONTH, 1);

      Xtvd xtvd = new Xtvd();
      soapRequest.getData(start, end, xtvd);

      Map<Integer, Station> stations = xtvd.getStations();

      for (final Entry<Integer, Station> entry : stations.entrySet()) {
        final Station station = entry.getValue();
        allChannels.add(
                new Channel(this, station.getName(), Integer.toString(station.getId()), TimeZone.getTimeZone("UTC"), "US", "(c) SchedulesDirect", "", mChannelGroup, null, Channel.CATEGORY_TV)
View Full Code Here

TOP

Related Classes of net.sf.xtvdclient.xtvd.datatypes.Xtvd

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.