<commit_before>package lan.dk.podcastserver.manager.worker.updater;

import lan.dk.podcastserver.entity.Item;
import lan.dk.podcastserver.entity.Podcast;
import lan.dk.podcastserver.utils.DateUtils;
import lan.dk.podcastserver.utils.DigestUtils;
import lan.dk.podcastserver.utils.ImageUtils;
import lan.dk.podcastserver.utils.jDomUtils;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.Namespace;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;

//@Scope("prototype")
@Component("RSSUpdater")
@Scope("prototype")
public class RSSUpdater extends AbstractUpdater {

    public Podcast updateFeed(Podcast podcast) {

        // Si l'image de présentation a changé :
        Document podcastXMLSource = null;
        try {
            podcastXMLSource = jDomUtils.jdom2Parse(podcast.getUrl());
        } catch (JDOMException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            return null;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            return null;
        }

        String currentCoverURL =
                (podcastXMLSource.getRootElement().getChild("channel").getChild("image") != null)
                        ? podcastXMLSource.getRootElement().getChild("channel").getChild("image").getChildText("url")
                        : null;

        Namespace media = Namespace.getNamespace("media", "http://search.yahoo.com/mrss/");
        Namespace feedburner = Namespace.getNamespace("feedburner", "http://rssnamespace.org/feedburner/ext/1.0");

        try {
            logger.debug("Traitement de la cover général du podcast");
            if (podcast.getCover() != null && currentCoverURL != null && !currentCoverURL.equals(podcast.getCover().getURL())) {
                podcast.setCover(ImageUtils.getCoverFromURL(new URL(currentCoverURL)));
            }<commit_msg>Suppression de l'update de la cover si celle-ci est déjà présente évitant les changement de cover intenpestive<commit_after>package lan.dk.podcastserver.manager.worker.updater;

import lan.dk.podcastserver.entity.Item;
import lan.dk.podcastserver.entity.Podcast;
import lan.dk.podcastserver.utils.DateUtils;
import lan.dk.podcastserver.utils.DigestUtils;
import lan.dk.podcastserver.utils.ImageUtils;
import lan.dk.podcastserver.utils.jDomUtils;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.Namespace;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;

//@Scope("prototype")
@Component("RSSUpdater")
@Scope("prototype")
public class RSSUpdater extends AbstractUpdater {

    public Podcast updateFeed(Podcast podcast) {

        // Si l'image de présentation a changé :
        Document podcastXMLSource = null;
        try {
            podcastXMLSource = jDomUtils.jdom2Parse(podcast.getUrl());
        } catch (JDOMException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            return null;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            return null;
        }

        String currentCoverURL =
                (podcastXMLSource.getRootElement().getChild("channel").getChild("image") != null)
                        ? podcastXMLSource.getRootElement().getChild("channel").getChild("image").getChildText("url")
                        : null;

        Namespace media = Namespace.getNamespace("media", "http://search.yahoo.com/mrss/");
        Namespace feedburner = Namespace.getNamespace("feedburner", "http://rssnamespace.org/feedburner/ext/1.0");

        try {
            if (podcast.getCover() == null) {
                logger.debug("Traitement de la cover général du podcast");
                podcast.setCover(ImageUtils.getCoverFromURL(new URL(currentCoverURL)));
            }

{'fraction_non_alphanumeric': 0.11174458380843785, 'fraction_numerical': 0.0031927023945267957, 'mean_word_length': 3.2011494252873565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3438402', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1222, 'n_words': 257}