<commit_before>from django.core.management.base import BaseCommand, CommandError

from bs4 import BeautifulSoup
import requests
from django_countries.data import COUNTRIES, COMMON_NAMES

from teami18n.models import Country, Podcast


class Command(BaseCommand):
    #args = '<poll_id poll_id ...>'
    help = 'Import Podcasts'

    def handle(self, *args, **options):
        for country in Country.objects.all():
            self.populate_podcasts(country)

    def populate_podcasts(country):
        country_name = COMMON_NAMES.get(country.code,
                                        COUNTRIES[country.code])
        url = ('http://api.npr.org/query?id=1001,1004'
               '&fields=title,teaser,show,image'
               '&requiredAssets=text,image,audio'
               '&dateType=story'
               '&startDate=2014-10-01'
               '&endDate=2014-10-31'
               '&searchTerm=' + country_name +
               '&sort=dateDesc'
               '&output=NPRML'
               '&numResults=50'
               '&apiKey=<KEY>')<commit_msg>Fix import<commit_after>from django.core.management.base import BaseCommand, CommandError

from bs4 import BeautifulSoup
import requests
from django_countries.data import COUNTRIES

from teami18n.models import Country, Podcast


class Command(BaseCommand):
    #args = '<poll_id poll_id ...>'
    help = 'Import Podcasts'

    def handle(self, *args, **options):
        for country in Country.objects.all():
            self.populate_podcasts(country)

    def populate_podcasts(country):
        country_name = unicode(COUNTRIES[country.code])
        url = ('http://api.npr.org/query?id=1001,1004'
               '&fields=title,teaser,show,image'
               '&requiredAssets=text,image,audio'
               '&dateType=story'
               '&startDate=2014-10-01'
               '&endDate=2014-10-31'
               '&searchTerm=' + country_name +
               '&sort=dateDesc'
               '&output=NPRML'
               '&numResults=50'
               '&apiKey=<KEY>')
{'fraction_non_alphanumeric': 0.11643835616438356, 'fraction_numerical': 0.02837573385518591, 'mean_word_length': 2.27724358974359, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3136336', 'n_tokens_mistral': 656, 'n_tokens_neox': 599, 'n_words': 110}