<commit_before>import os
import time
import urllib
import urllib2
import logging
import shutil
import filecmp
from flexget.plugin import *
from sqlalchemy import Column, String, Integer, DateTime
from flexget.manager import Base
from datetime import datetime

log = logging.getLogger('download')

class Download(Base):

    __tablename__ = 'download_history'
    
    id = Column(Integer, primary_key=True)
    feed = Column(String)
    filename = Column(String)
    url = Column(String)
    title = Column(String)
    time = Column(DateTime)
    details = Column(String)
    
    def __init__(self):
        self.time = datetime.now()
    
    def __str__(self):
        return '<Download(filename=%s,feed=%s)>' % (self.filename, self.feed)


class PluginDownloads:

    """
        Provides --downloads
    """

    def on_process_start(self, feed):

        # temp hack for database change
        from flexget.manager import Session
        from flexget.utils.sqlalchemy_utils import table_columns, table_schema
        columns = table_columns('download_history', Session())
        if not 'details' in columns:
            log.critical('Please see bleeding edge news for neccessary actions')
            log.critical('Re-cap run: sqlite3 %s "drop table download_history;"' % feed.manager.db_filename)
            import sys
            sys.exit(1)

        if feed.manager.options.downloads:
            from flexget.manager import Session
            feed.manager.disable_feeds()
            session = Session()
            print '-- Downloads: ' + '-' * 65
            for download in session.query(Download).order_by(Download.time)[-50:]:
                print ' Title  : %s' % download.title
                print ' Url    : %s' % download.url
                print ' Stored : %s' % download.filename
                print ' Time   : %s' % download.time.strftime("%c")
                print '-' * 79
            session.close()


class PluginDownload:

    """
        Downloads content from entry url and writes it into a file.
        
        Example:

        download: ~/torrents/
        
        Allow HTML content:
        
        By default download plugin reports failure if received content
        is a html. Usually this is some sort of custom error page without
        proper http code and thus entry is assumed to be downloaded 
        incorrectly.
        
        In the rare case you actually need to retrieve html-pages you must
        disable this feature.
        
        download:
          path: ~/something/
          fail_html: no

        You may use commandline parameter --dl-path to temporarily override <commit_msg>Added details line into --downloads<commit_after>import os
import time
import urllib
import urllib2
import logging
import shutil
import filecmp
from flexget.plugin import *
from sqlalchemy import Column, String, Integer, DateTime
from flexget.manager import Base
from datetime import datetime

log = logging.getLogger('download')

class Download(Base):

    __tablename__ = 'download_history'
    
    id = Column(Integer, primary_key=True)
    feed = Column(String)
    filename = Column(String)
    url = Column(String)
    title = Column(String)
    time = Column(DateTime)
    details = Column(String)
    
    def __init__(self):
        self.time = datetime.now()
    
    def __str__(self):
        return '<Download(filename=%s,feed=%s)>' % (self.filename, self.feed)


class PluginDownloads:

    """
        Provides --downloads
    """

    def on_process_start(self, feed):

        # temp hack for database change
        from flexget.manager import Session
        from flexget.utils.sqlalchemy_utils import table_columns, table_schema
        columns = table_columns('download_history', Session())
        if not 'details' in columns:
            log.critical('Please see bleeding edge news for neccessary actions')
            log.critical('Re-cap run: sqlite3 %s "drop table download_history;"' % feed.manager.db_filename)
            import sys
            sys.exit(1)

        if feed.manager.options.downloads:
            from flexget.manager import Session
            feed.manager.disable_feeds()
            session = Session()
            print '-- Downloads: ' + '-' * 65
            for download in session.query(Download).order_by(Download.time)[-50:]:
                print ' Title   : %s' % download.title
                print ' Url     : %s' % download.url
                print ' Stored  : %s' % download.filename
                print ' Time    : %s' % download.time.strftime("%c")
                if feed.manager.options.details:
                    print ' Details : %s' % download.details
                print '-' * 79
            session.close()


class PluginDownload:

    """
        Downloads content from entry url and writes it into a file.
        
        Example:

        download: ~/torrents/
        
        Allow HTML content:
        
        By default download plugin reports failure if received content
        is a html. Usually this is some sort of custom error page without
        proper http code and thus entry is assumed to be downloaded 
        incorrectly.
        
        In the rare case you actually need to retrieve html-pages you must
        disable this feature.
        
        download:
          path: ~/something/
          fail_html: no

        You may use commandline parameter --dl-path to temporarily override 
{'fraction_non_alphanumeric': 0.08214154748808214, 'fraction_numerical': 0.0033003300330033004, 'mean_word_length': 2.1314580941446613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '953729', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1398, 'n_words': 466}