<commit_before>$ = require('jquery')

AudioFile = require('./audio_file.coffee')

class FeedItem
  constructor: (@xml) ->
    @media = {}
    @parse()

  parse: () =>
    @title = @extract('title').html()
    @subtitle = @extract('subtitle').html() ||
      @extract('itunes\\:subtitle').html()
    @href = @extract('link').html()
    @enclosure = @mapEnclosure()
    @description = @extract('description').html()

  extract: (elemName) =>
    @[elemName] ?= $(@xml).find(elemName)

  mapEnclosure: () =>
    enclosure = @extract('enclosure')
    url = enclosure.attr('url')
    type = enclosure.attr('type')
    @media[@enclosureMapping(type)] = url
    @media

  enclosureMapping: (type) -><commit_msg>fixes feed description extraction<commit_after>$ = require('jquery')

AudioFile = require('./audio_file.coffee')

class FeedItem
  constructor: (@xml) ->
    @media = {}
    @parse()

  parse: () =>
    @title = @extract('title').html()
    @subtitle = @extract('subtitle').html() ||
      @extract('itunes\\:subtitle').html()
    @href = @extract('link').html()
    @enclosure = @mapEnclosure()
    @description = @extract('description')
      .html()
      .match(/<!\[CDATA\[([\s\S]*)]]>$/)[1]

  extract: (elemName) =>
    @[elemName] ?= $(@xml).find(elemName)

  mapEnclosure: () =>
    enclosure = @extract('enclosure')
    url = enclosure.attr('url')
    type = enclosure.attr('type')
    @media[@enclosureMapping(type)] = url
    @media

  enclosureMapping: (type) ->
{'fraction_non_alphanumeric': 0.213657876943881, 'fraction_numerical': 0.000676132521974307, 'mean_word_length': 3.6105919003115265, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6483088', 'n_tokens_mistral': 504, 'n_tokens_neox': 481, 'n_words': 81}