+# Take an encoded url_encoded_fmt_stream_map and return a hash
+# matching video IDs to download URLs
+sub _decode_url_encoded_fmt_stream_map {
+ my $self = shift;
+ my $data = shift;
+ my $dataencoded = shift;
+ my @data;
+
+ $data = $self->decode_hexurl($data) if $dataencoded;
+ # This will
+ # - Split the decoded string into segments (along ,)
+ # - Interpret each segment as a concatenated key-value list (key and value separated by =, pairs separated by &
+ # - URL-decode each key and value _again_
+ #
+ # @data will be an array of hash references
+
+ @data = map { { map { $self->decode_hexurl($_) } split /[&=]/ } } split /,/, $data;
+ $self->debug("_decode_url_encoded_fmt_stream_map() decoded %s", Dumper(\@data));
+
+ # From each array entry, pick the itag and the url values and return that
+ # as a hash reference
+
+ return { map { $_->{'itag'}, $_->{'url'} } @data };
+}
+
+
+