finalized algorithm for playlist parser