Giter Club home page Giter Club logo

Comments (4)

Illyism avatar Illyism commented on September 25, 2024 1

Hey there

You can just get the JSON data from Reddit: http://reddit.com/r/listentothis.json

See the Reddit API for details: https://www.reddit.com/dev/api/

To know if a link is playable, I do the following check: https://github.com/Illyism/musicplayer/blob/master/src/modules/playlist/util/isPlayable.ts

from redditmusicplayer.

gordielachance avatar gordielachance commented on September 25, 2024

Ok... So you don't extract the artist / tile out of the reddit posts ? I need a clean way to get them (no genre/year/text...)

from redditmusicplayer.

Illyism avatar Illyism commented on September 25, 2024

@gordielachance No, I just show the Reddit title. Let me know if you find a solution! I'd love to see it too.

from redditmusicplayer.

gordielachance avatar gordielachance commented on September 25, 2024

well, I had worked on some piece of code but of course, it's not perfect.
The goal is to extract the track artist and track name out of the node title.

artist regex pattern:

(?:(?:.*), +by +(.*))|(?:(.*)(?: +[-|–|—]+ +)(?:.*))

title regex pattern:

(?:(.*), +by +(?:.*))|(?:(?:.*)(?: +[-|–|—]+ +)(.*))

then I try to clean those strings the best I can (here in Ruby) :

def clean_string(str)

  #remove quotation marks
  ignore_wrappers = ['"','\'']
  ignore_wrappers.each do |wrapper|
    str.delete_prefix(wrapper).delete_suffix(wrapper)
  end

  #remove some specific strings
  ignore_words = [
    '(Audio)',
    '(Official)',
    '(Official Video)',
    '(Official Audio)',
    '(Official Videoclip)',
    '(Clip officiel)',
    '(Lyric Video)',
    '(Official Music Video)',
    '(HD)',
    '(Music Video)',
    '(High Quality)',
    ' HD',
    ' HQ',
  ]

  ignore_words.each do |word|
    str.gsub! word, ''
  end

  #remove some regexes
  ignore_regexes = [
    '\[.*\]', #eg [Hip-Hop]
    '\(\d{4}\)', #dates - eg. (1968)
    '\d{4} ?$', #dates (end of string) eg. 2005
    '[-|–|—] *$' #dash (end of string)
  ]

  ignore_regexes.each do |regex|
    pattern = Regexp.new(regex)
    str = str.gsub(pattern, '')
  end

  str.strip

end

Of course, this is completely arbitrary. But it sometimes work quite well.

from redditmusicplayer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.