module Nehm
  class Track
    attr_reader :hash

    def initialize(hash)
      @hash = hash
    end

    def artist
      if @hash['title'].index(' - ')
        @hash['title'].split(' - ')[0]
      else
        @hash['user']['username']
      end
    end

    def artwork
      Artwork.new(self)
    end

    def file_name
      "#{name}.mp3".tr("/'\"", '')
    end

    def file_path
      File.join(PathManager.dl_path, file_name)
    end

    def id
      @hash['id']
    end

    # Used in Get#dl and in Track#file_name
    def name
      artist + ' - ' + title
    end

    def streamable?
      @hash['streamable']
    end

    def title
      if @hash['title'].index(' - ')
        @hash['title'].split(' - ')[1]
      else
        @hash['title']
      end
    end

    def url
      "#{@hash['stream_url']}?client_id=#{Client::CLIENT_ID}"
    end

    def year
      @hash['created_at'][0..3].to_i
    end
  end
end

module Nehm
  class Track
    attr_reader :hash

    def initialize(hash)
      @hash = hash
    end

    def artist
      if @hash['title'].include?('-')
        title = @hash['title'].split('-')
        title[0].rstrip
      else
        @hash['user']['username']
      end
    end

    def artwork
      Artwork.new(self)
    end

    def file_name
      "#{name}.mp3".tr("/'\"", '')
    end

    def file_path
      File.join(PathManager.dl_path, file_name)
    end

    def id
      @hash['id']
    end

    # Used in Get#dl and in Track#file_name
    def name
      artist + ' - ' + title
    end

    def streamable?
      @hash['streamable']
    end

    def title
      if @hash['title'].include?('-')
        title = @hash['title'].split('-')
        title[1].lstrip
      else
        @hash['title']
      end
    end

    def url
      "#{@hash['stream_url']}?client_id=#{Client::CLIENT_ID}"
    end

    def year
      @hash['created_at'][0..3].to_i
    end
  end
end

--- 
+++ 
@@ -7,9 +7,8 @@
     end
 
     def artist
-      if @hash['title'].include?('-')
-        title = @hash['title'].split('-')
-        title[0].rstrip
+      if @hash['title'].index(' - ')
+        @hash['title'].split(' - ')[0]
       else
         @hash['user']['username']
       end
@@ -41,9 +40,8 @@
     end
 
     def title
-      if @hash['title'].include?('-')
-        title = @hash['title'].split('-')
-        title[1].lstrip
+      if @hash['title'].index(' - ')
+        @hash['title'].split(' - ')[1]
       else
         @hash['title']
       end
Fix detection of artist in title name of song
